Querying Salesforce
Learn how to write SOQL queries to pull SFDC data into Pocus.
Pulling Data from Salesforce
To grab data from Salesforce directly, Pocus uses the Salesforce API with Salesforce’s own query language - SOQL. It’s like SQL, but with some missing functionalities and intricacies. If you’re unfamiliar, leverage the Salesforce documentation to learn more. This guide will give you some quick tips but is by no means exhaustive.
SELECT Id, APIName, Name, BillingCity, Custom_field__c
FROM ContactsObject
Declare the object you want to pull from with a, you guessed it, FROM. Default objects are plural and CamelCase (Contacts, Accounts, Opportunities, CampaignMembers) and custom objects have an __c at the end (e.g., Workspaces__c).
Fields
Declare the fields you want to pull in by using their API Names.
- Default Fields
- Default SFDC fields are CamelCase
- Custom Fields
- Custom SFDC fields are Snake_Case with an appended
__c- yep that is 2 underscores!
- Custom SFDC fields are Snake_Case with an appended
- Relationship Fields
- Salesforce objects have relationships to one another via lookup fields. If one object has a lookup field on another, you can pull fields from that nested object into the current one you are querying, this should work up to 3 levels of nesting for example
- Contact → Account → User
- The contact object has a lookup to the account, which in turn has a lookup to a Salesforce user that is the owner of the Account. If you are on the contact query and would like to pull in the email of the User that owns the Account with which a contact is associated, you can do this by querying for
Account.Owner.Emailon the Contact. - If you were on the Account, instead of querying
OwnerIdwhich would bejdh2738djjsj, you can just doOwner.Email - Other common examples,
Opportunity.CloseDate - You can do the same with custom relationship/lookup fields with one little trick. Change the
__cto a__r- For example, if there is a custom ownership field
Customer_Success_Owner__cthat is returning a Salesforce Idjdh2738djjsjquery forCustomer_Success_Owner__r.NameorCustomer_Success_Owner__r.Emailto get the Name or Email of the Customer Success Owner.
- For example, if there is a custom ownership field
- Salesforce objects have relationships to one another via lookup fields. If one object has a lookup field on another, you can pull fields from that nested object into the current one you are querying, this should work up to 3 levels of nesting for example
Updated 11 months ago
What’s Next