turbot/salesforce
steampipe plugin install salesforce

Table: salesforce_contract - Query Salesforce Contracts using SQL

Salesforce Contracts are a record of the agreements between your company and the customers. They contain details such as the contract term (start and end date), contract status, associated account, and other related information. Contracts in Salesforce help to maintain the details of the service or support agreed upon during a sale.

Table Usage Guide

The salesforce_contract table provides insights into contracts within Salesforce. As a Salesforce administrator, you can explore contract-specific details through this table, including the contract's status, its start and end dates, and the associated account. Use it to uncover information about contracts, such as those that are nearing their end dates, or to verify the details of a specific contract.

Important Notes

  • If the naming_convention configuration argument is set to api_native, please see API Native Examples.

Examples

Basic info

Gain insights into your company's contractual agreements, including the duration and status, to better manage your business relationships and plan for future engagements. This will assist in understanding the overall contract lifecycle within your organization.

select
id,
account_id,
contract_number,
contract_term,
end_date,
start_date,
company_signed_date,
status
from
salesforce_contract;
select
id,
account_id,
contract_number,
contract_term,
end_date,
start_date,
company_signed_date,
status
from
salesforce_contract;

List contracts signed in the last six months

Discover the contracts that have been signed in the past six months to understand the recent business dealings and their status. This can be useful in assessing the volume and nature of recent contractual agreements.

select
id,
account_id,
contract_number,
contract_term,
end_date,
start_date,
company_signed_date,
status
from
salesforce_contract
where
company_signed_date >= (current_date - interval '6' month);
select
id,
account_id,
contract_number,
contract_term,
end_date,
start_date,
company_signed_date,
status
from
salesforce_contract
where
company_signed_date >= date('now', '-6 month');

List number of contracts by status

This query allows you to analyze the distribution of contracts within your Salesforce data according to their status. It aids in assessing the overall contract management efficiency and identifying areas that might need attention or improvement.

select
count(*),
status
from
salesforce_contract
group by
status;
select
count(*),
status
from
salesforce_contract
group by
status;

API Native Examples

If the naming_convention config argument is set to api_native, the table and column names will match Salesforce naming conventions.

Basic info (with API Native naming convention)

Discover the segments that pertain to specific contract details such as term length and status. This can help in understanding the distribution and status of different contracts within an account.

select
"ID",
"AccountID",
"ContractNumber",
"ContractTerm",
"EndDate",
"StartDate",
"Status"
from
"Contract";
select
"ID",
"AccountID",
"ContractNumber",
"ContractTerm",
"EndDate",
"StartDate",
"Status"
from
"Contract";

List number of contracts by status (with API Native naming convention)

Determine the distribution of contracts based on their status to understand the operational dynamics of your business. This can help you identify areas that may require attention or improvement.

select
count(*),
"Status"
from
"Contract"
group by
"Status";
select
count(*),
"Status"
from
"Contract"
group by
"Status";

Show draft contracts

Explore which contracts are still in draft status to understand potential upcoming agreements and their terms. This could help in planning resources or assessing future commitments.

select
"ID",
"AccountID",
"ContractNumber",
"ContractTerm",
"EndDate",
"StartDate",
"Status"
from
"Contract"
where
"Status" = 'Draft';
select
"ID",
"AccountID",
"ContractNumber",
"ContractTerm",
"EndDate",
"StartDate",
"Status"
from
"Contract"
where
"Status" = 'Draft';

Show deleted contracts

Discover the contracts that have been deleted to understand any potential impact on business operations or account management. This can be useful in identifying gaps in service or potential revenue loss.

select
"ID",
"AccountID",
"ContractNumber",
"ContractTerm",
"EndDate",
"StartDate",
"Status"
from
"Contract"
where
"IsDeleted";
select
"ID",
"AccountID",
"ContractNumber",
"ContractTerm",
"EndDate",
"StartDate",
"Status"
from
"Contract"
where
"IsDeleted";

Schema for salesforce_contract

NameTypeOperatorsDescription
_ctxjsonbSteampipe context in JSON form, e.g. connection_name.
account_idtextID of the Account associated with this contract.
activated_by_idtextID of the User who activated this contract.
activated_datetimestamp with time zoneDate and time when this contract was activated.
billing_addressjsonbBilling address of the account.
company_signed_datetimestamp with time zoneDate on which the contract was signed by organization.
company_signed_idtextID of the User who signed the contract.
contract_numbertextNumber of the contract.
contract_termbigintNumber of months that the contract is valid.
created_by_idtextId of the user who created the contract record.
created_datetimestamp with time zoneDate and time when contract record was created.
customer_signed_datetimestamp with time zoneDate on which the customer signed the contract.
customer_signed_idtextID of the Contact who signed this contract.
customer_signed_titletextTitle of the contact who signed the contract.
descriptiontextStatement describing the contract.
end_datetimestamp with time zoneCalculated end date of the contract. This value is calculated by adding the ContractTerm to the start_date.
idtextUnique identifier of the contract in Salesforce.
is_deletedbooleanIndicates whether the object has been moved to the Recycle Bin (true) or not (false).
last_activity_datetimestamp with time zoneValue is one of the following, whichever is the most recent. a) Due date of the most recent event logged against the record. b) Due date of the most recently closed task associated with the record.
last_approved_datetimestamp with time zoneLast date the contract was approved.
last_modified_by_idtextThe id of user who most recently changed the contract record.
last_modified_datetimestamp with time zoneThe date and time of the last change to contract record.
last_referenced_datetimestamp with time zoneThe timestamp when the current user last accessed this record, a record related to this record, or a list view.
last_viewed_datetimestamp with time zoneThe timestamp when the current user last viewed this record or list view. If this value is null, the user might have only accessed this record or list view (last_referenced_date) but not viewed it.
owner_expiration_noticetextNumber of days ahead of the contract end date (15, 30, 45, 60, 90, and 120). Used to notify the owner in advance that the contract is ending.
owner_idtextID of the user who owns the contract.
pricebook_2_idtextID of the pricebook, if any, associated with this contract.
special_termstextSpecial terms that apply to the contract.
start_datetimestamp with time zoneStart date for this contract.
statustextThe picklist of values that indicate order status. A contract can be Draft, InApproval, or Activated.
system_modstamptimestamp with time zoneThe date and time when contract was last modified by a user or by an automated process.

Export

This table is available as a standalone Exporter CLI. Steampipe exporters are stand-alone binaries that allow you to extract data using Steampipe plugins without a database.

You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_export_installer.sh script:

/bin/sh -c "$(curl -fsSL https://steampipe.io/install/export.sh)" -- salesforce

You can pass the configuration to the command with the --config argument:

steampipe_export_salesforce --config '<your_config>' salesforce_contract