turbot/salesforce

GitHub
steampipe plugin install salesforcesteampipe plugin install salesforce

Salesforce + Steampipe

Salesforce is a customer relationship management (CRM) platform.

Steampipe is an open source CLI to instantly query cloud APIs using SQL.

List won opportunities:

select
name,
amount,
close_date
from
salesforce_opportunity
where
is_won;
+-------------------------------------+--------+---------------------------+
| name | amount | close_date |
+-------------------------------------+--------+---------------------------+
| GenePoint Standby Generator | 85000 | 2021-10-23T05:30:00+05:30 |
| GenePoint SLA | 30000 | 2021-12-16T05:30:00+05:30 |
| Express Logistics Standby Generator | 220000 | 2021-09-15T05:30:00+05:30 |
+-------------------------------------+------------------------------------+

Documentation

Get started

Install

Download and install the latest salesforce plugin:

steampipe plugin install salesforce

Configuration

Installing the latest salesforce plugin will create a config file (~/.steampipe/config/salesforce.spc) with a single connection named salesforce:

connection "salesforce" {
plugin = "salesforce"
# Salesforce instance URL, e.g., "https://na01.salesforce.com/"
# url = "https://na01.salesforce.com/"
# Salesforce account name
# username = "user@example.com"
# Salesforce account password
# password = "Dummy@~Password"
# The Salesforce security token is only required If the client's IP address is not added to the organization's list of trusted IPs
# https://help.salesforce.com/s/articleView?id=sf.security_networkaccess.htm&type=5
# token = "ABO5C3PNqOP0BHsPFakeToken"
# Salesforce client ID of the connected app
# client_id = "3MVG99E3Ry5mh4z_FakeID"
# List of Salesforce object names to generate additional tables for
# This argument only accepts exact Salesforce standard and custom object names, e.g., AccountBrand, OpportunityStage, CustomApp__c
# For a full list of standard object names, please see https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_list.htm)
# All custom object names should end in "__c", following Salesforce object naming standards
# objects = ["AccountBrand", "OpportunityStage", "CustomApp__c"]
# Salesforce API version to connect to
# api_version = "43.0"
}

Credentials

Custom Fields

Salesforce supports the addition of custom fields to standard objects.

If you have set up Salesforce credentials correctly in the Steampipe configuration, Steampipe will generate the tables schema with all the custom fields along with standard object fields dynamically.

For instance, if the Account object in my Salesforce account has a custom field with the label Priority and the API name Priority__c, the table schema will be generated as:

.inspect salesforce_account
+-----------------------+--------------------------+-------------------------------------------------------------+
| column | type | description |
+-----------------------+---------------------------+------------------------------------------------------------+
| account_number | text | The Account Number. |
| account_source | text | The source of the account record. For example, Advertisement, Data.com, or Trade Show. |
| priority__c | text | The account's priority. |
+----------------+------+----------------------------------------------------------------------------------------+

The custom field priority__c column can then be queried like other columns:

select
account_number,
priority__c
from
salesforce_account;

Note: Salesforce custom field names are always suffixed with __c, which is reflected in the column names as well.

Custom Objects

Salesforce also supports creating custom objects to track and store data that's unique to your organization.

Steampipe will create table schemas for all custom objects set in the objects argument.

For instance, if my connection configuration is:

connection "salesforce" {
plugin = "salesforce"
url = "https://my-dev-env.my.salesforce.com"
username = "user@example.com"
password = "MyPassword"
token = "MyToken"
client_id = "MyClientID"
objects = ["CustomApp__c", "OtherCustomApp__c"]
}

Steampile will automatically create two tables, salesforce_custom_app__c and salesforce_other_custom_app__c, which can then be inspected and queried like other tables:

.inspect salesforce
+---------------------------------+---------------------------------------------------------+
| table | description |
+---------------------------------+---------------------------------------------------------+
| salesforce_account_contact_role | Represents the role that a Contact plays on an Account. |
| salesforce_custom_app__c | Represents Salesforce object CustomApp__c. |
| salesforce_other_custom_app__c | Represents Salesforce object OtherCustomApp__c. |
+---------------------------------+---------------------------------------------------------+

To get details of a specific custom object table, inspect it by name:

.inspect salesforce_custom_app__c
+---------------------+--------------------------+-------------------------+
| column | type | description |
+---------------------+--------------------------+-------------------------+
| created_by_id | text | ID of app creator. |
| created_date | timestamp with time zone | Created date. |
| id | text | App record ID. |
| is_deleted | boolean | True if app is deleted. |
| last_modified_by_id | text | ID of last modifier. |
| last_modified_date | timestamp with time zone | Last modified date. |
| name | text | App name. |
| owner_id | text | Owner ID. |
| system_modstamp | timestamp with time zone | System Modstamp. |
+---------------------+--------------------------+-------------------------+

This table can also be queried like other tables:

select
*
from
salesforce_custom_app__c;

Note: Salesforce custom object names are always suffixed with __c, which is reflected in the table names as well.

Get involved