Salesforce Record Lookups

Salesforce Record Lookups

Introduction

Efficient data retrieval is essential for seamless Salesforce integration, and API-based lookups play a key role in this process. This guide explores how to perform Salesforce record lookups programmatically, enabling dynamic data access and automation. It details the request methods, headers, and query structures required to search for Contacts, Cases, and other objects. Additionally, the article explains how to utilize Logic+ flow variables to store and manipulate retrieved data, ensuring smooth and efficient data handling within your integrations.

When constructing the URL path, request headers, or request body, you may notice variables marked with $() syntax (for example, $(cidNumber)). These variables must be defined earlier in your Logic+ flow before they can be used. A common way to set these variables is by performing an ANI lookup operation to retrieve the callers phone number, which can then be passed into these integration panels.

Handling Record IDs from Salesforce API Lookups

When performing a lookup using Salesforce APIs, a Record ID is returned. In the attached templates, alongside the Integration Panel, there is a Set Variable Panel, which assigns the returned Record ID to the appropriate field based on the type of record found:

  • externalCRMID – If a Contact is found

  • externalCRMAccountID – If an Account is found

  • externalCaseID – If a Case is found

The Record ID is essential for enabling screen pop functionality when utilizing the CTI. As long as a matching record is found, the corresponding field is populated accordingly.

For reference, the Record ID can be located within the Salesforce URL, as demonstrated in the attached screenshot.

sfidURL.png

Contact Lookup

Contacts in Salesforce represent individuals associated with Accounts. The Contact lookup API operation helps you find and retrieve contact information from your Salesforce organization.

API Overview: The Contact lookup operation supports searching for contacts using fields like Email, Phone, Name, or any custom fields. The API returns detailed contact information, including related accounts and activity history.

Integration Panel Settings Example

Integration*:

Select your integration's base URL from the dropdown menu. This URL should have been configured during your initial setup on the Integrations page.

Path:

/services/data/v59.0/query/?q=SELECT+Id,Name,Phone+FROM+Contact+WHERE+Phone='$(cidNumber)'

Request Method:

GET

Request Headers:

{ "Content-Type": "application/json; charset=UTF-8", "Authorization": "OAuth $(accessToken1)$(accessToken2)" }

Request Body:

The request body is not required for this API call.

Content Type:

JSON

Variables:

Define a variable to store your token, using the JSONPath syntax as demonstrated below.

$.data.0.message
statusText
$.data.records.0.Id
$.data.records.0.Name

Contact Look Up Logic+ JSON Template

{ "panels":[ { "type": "integration", "initiator": true, "name": "contactLookUp", "coordinates": { "x": 546, "y": 417 }, "fields": { "integrationId": "004hq3tmn7b4pyfv84", "path": "/services/data/v59.0/query/?q=SELECT+Id,Name,Phone+FROM+Contact+WHERE+Phone='$(cidNumber)'", "method": "GET", "headers": { "Content-Type": "application/json; charset=UTF-8", "Authorization": "OAuth $(accessToken1)$(accessToken2)" }, "contentType": "JSON", "timeout": 10, "variables": [ { "name": "errorMessage", "jsonpath": "$.data.0.message" }, { "name": "contactId", "jsonpath": "$.data.records.0.Id" }, { "name": "contactName", "jsonpath": "$.data.records.0.Name" }, { "name": "status", "jsonpath": "statusText" } ], "fireAndForget": false }, "exits": { "default": "setExternalCRMId", "timeout": "setExternalCRMId", "error": "setExternalCRMId" }, "version": "2.2.0" }, { "type": "setVariable", "initiator": false, "name": "setExternalCRMId", "coordinates": { "x": 1004.5, "y": 472.5 }, "fields": { "variables": [ { "name": "externalCRMID", "value": "$(contactId)" } ] }, "exits": { "default": "" }, "version": "2.0.0" } ] }

Account Lookup

Salesforce Accounts represent organizations, individual customers, or partners that you do business with. The Account lookup API operation allows you to retrieve account information using unique identifiers or search criteria.

API Overview: The Account lookup operation uses the SOQL (Salesforce Object Query Language) or the REST API's query endpoint to search for and retrieve account records. This operation supports filtering by various fields such as Account Name, Account Number, or custom fields.

Integration Panel Settings Example

Integration*:

Select your integration's base URL from the dropdown menu. This URL should have been configured during your initial setup on the Integrations page.

Path:

/services/data/v59.0/query/?q=SELECT+Id,Name,Phone+FROM+Account+WHERE+Phone='$(cidNumber)'

Request Method:

GET

Request Headers:

{ "Content-Type": "application/json; charset=UTF-8", "Authorization": "OAuth $(accessToken1)$(accessToken2)" }

Request Body:

The request body is not required for this API call.

Content Type:

JSON

Variables:

Define a variable to store your token, using the JSONPath syntax as demonstrated below.

$.data.0.message
statusText
$.data.records.0.Id
$.data.records.0.Name

Account Look Up Logic+ JSON Template

{ "panels":[ { "type": "integration", "initiator": true, "name": "accountLookUp", "coordinates": { "x": 104, "y": 408 }, "fields": { "integrationId": "004hq3tmn7b4pyfv84", "path": "/services/data/v59.0/query/?q=SELECT+Id,Name,Phone+FROM+Account+WHERE+Phone='$(cidNumber)'", "method": "GET", "headers": { "Content-Type": "application/json; charset=UTF-8", "Authorization": "OAuth $(accessToken1)$(accessToken2)" }, "contentType": "JSON", "timeout": 10, "variables": [ { "name": "errorMessage", "jsonpath": "$.data.0.message" }, { "name": "accountId", "jsonpath": "$.data.records.0.Id" }, { "name": "accountName", "jsonpath": "$.data.records.0.Name" }, { "name": "status", "jsonpath": "statusText" } ], "fireAndForget": false }, "exits": { "default": "setExternalCRMAccountId", "timeout": "setExternalCRMAccountId", "error": "setExternalCRMAccountId" }, "version": "2.2.0" }, { "type": "setVariable", "initiator": false, "name": "setExternalCRMAccountId", "coordinates": { "x": 601.5, "y": 453.16666666666674 }, "fields": { "variables": [ { "name": "externalCRMAccountID", "value": "$(accountId)" } ] }, "exits": { "default": "" }, "version": "2.0.0" } ] }

Case Lookup

Cases in Salesforce are used to track and solve customer issues or problems. The Case lookup API operation enables you to retrieve case information and track the status of customer support tickets.

API Overview: The Case lookup API allows you to search for cases using various criteria such as Case Number, Status, Priority, or related Account/Contact information. This operation supports both simple and complex queries to retrieve case details.

Integration Panel Settings Example

Integration*:

Select your integration's base URL from the dropdown menu. This URL should have been configured during your initial setup on the Integrations page.

Path:

/services/data/v59.0/query/?q=SELECT+Id,CaseNumber,Subject,Status+FROM+Case+WHERE+ContactPhone='$(cidNumber)'
GET

Request Headers:

{ "Content-Type": "application/json; charset=UTF-8", "Authorization": "OAuth $(accessToken1)$(accessToken2)" }

Request Body:

The request body is not required for this API call.

Content Type:

JSON

Variables:

Define a variable to store your token, using the JSONPath syntax as demonstrated below.

$.data.0.message
statusText
$.data.records.0.Id

Case Look Up Logic+ JSON Template

{ "panels":[ { "type": "integration", "initiator": true, "name": "caseLookup", "coordinates": { "x": 297.84874821659105, "y": 197.6774231050997 }, "fields": { "integrationId": "004hq3tmn7b4pyfv84", "path": "/services/data/v59.0/query/?q=SELECT+Id,CaseNumber,Subject,Status+FROM+Case+WHERE+ContactPhone='$(cidNumber)'", "method": "GET", "headers": { "Content-Type": "application/json; charset=UTF-8", "Authorization": "OAuth $(accessToken1)$(accessToken2)" }, "contentType": "JSON", "timeout": 15, "variables": [ { "name": "caseId", "jsonpath": "$.data.records.0.Id" }, { "name": "errorMessage", "jsonpath": "$.data.0.message" }, { "name": "status", "jsonpath": "statusText" } ], "fireAndForget": false }, "exits": { "default": "setExternalCaseID", "timeout": "setExternalCaseID", "error": "setExternalCaseID" }, "version": "2.2.0" }, { "type": "setVariable", "initiator": false, "name": "setExternalCaseID", "coordinates": { "x": 752.348748216591, "y": 265.1774231050997 }, "fields": { "variables": [ { "name": "externalCaseID", "value": "$(caseId)" } ] }, "exits": { "default": "" }, "version": "2.0.0" } ] }