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 toapi_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, statusfrom salesforce_contract;
select id, account_id, contract_number, contract_term, end_date, start_date, company_signed_date, statusfrom 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, statusfrom salesforce_contractwhere company_signed_date >= (current_date - interval '6' month);
select id, account_id, contract_number, contract_term, end_date, start_date, company_signed_date, statusfrom salesforce_contractwhere 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(*), statusfrom salesforce_contractgroup by status;
select count(*), statusfrom salesforce_contractgroup 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
Name | Type | Operators | Description |
---|---|---|---|
_ctx | jsonb | Steampipe context in JSON form. | |
account_id | text | ID of the Account associated with this contract. | |
activated_by_id | text | ID of the User who activated this contract. | |
activated_date | timestamp with time zone | Date and time when this contract was activated. | |
billing_address | jsonb | Billing address of the account. | |
company_signed_date | timestamp with time zone | Date on which the contract was signed by organization. | |
company_signed_id | text | ID of the User who signed the contract. | |
contract_number | text | Number of the contract. | |
contract_term | bigint | Number of months that the contract is valid. | |
created_by_id | text | Id of the user who created the contract record. | |
created_date | timestamp with time zone | Date and time when contract record was created. | |
customer_signed_date | timestamp with time zone | Date on which the customer signed the contract. | |
customer_signed_id | text | ID of the Contact who signed this contract. | |
customer_signed_title | text | Title of the contact who signed the contract. | |
description | text | Statement describing the contract. | |
end_date | timestamp with time zone | Calculated end date of the contract. This value is calculated by adding the ContractTerm to the start_date. | |
id | text | Unique identifier of the contract in Salesforce. | |
is_deleted | boolean | Indicates whether the object has been moved to the Recycle Bin (true) or not (false). | |
last_activity_date | timestamp with time zone | Value 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_date | timestamp with time zone | Last date the contract was approved. | |
last_modified_by_id | text | The id of user who most recently changed the contract record. | |
last_modified_date | timestamp with time zone | The date and time of the last change to contract record. | |
last_referenced_date | timestamp with time zone | The timestamp when the current user last accessed this record, a record related to this record, or a list view. | |
last_viewed_date | timestamp with time zone | The 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_notice | text | Number 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_id | text | ID of the user who owns the contract. | |
pricebook_2_id | text | ID of the pricebook, if any, associated with this contract. | |
sp_connection_name | text | Steampipe connection name. | |
sp_ctx | jsonb | Steampipe context in JSON form. | |
special_terms | text | Special terms that apply to the contract. | |
start_date | timestamp with time zone | Start date for this contract. | |
status | text | The picklist of values that indicate order status. A contract can be Draft, InApproval, or Activated. | |
system_modstamp | timestamp with time zone | The 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