searchObject

Reading Time: 1 minute

Returns a Salesforce object (e.g., lead or contact) you specify containing the Salesforce ID of a record if a match is found.

Description

salesforce.searchObject(salesforceURL: string, accessToken: string, searchParams: object, callback: Function)

Parameters

salesforceURL
The url of your Salesforce instance (e.g.,: https://eu26.lightning.force.com/)

accessToken
A valid access token which grants access to your Salesforce instance. It can be generated using the getAccessToken method.

searchParams
An object in which you can specify the following parameter values: searchValue, salesforceObject, searchIn. (SearchIn field may contain: ALL, NAME, EMAIL, PHONE, or SIDEBAR values.)

callback
Receives the result of the search as parameter when a match is found. In the body of the function, set the value of the returned object’s Salesforce ID to your Salesforce field that was created during the setup procedure. (E.g., vcc.setFieldValue(‘salesforce_id’, result.searchRecords[0].Id); )

Return values

Returns a Salesforce object (e.g., a lead or contact) you specify if a match is found based on the phone number.

Example

function showLeadInSalesforce(phoneNumber) {
  salesforce.getAccessToken(config, 'api', function(accessToken) {
      token = accessToken;
         searchParams = {
          'searchValue': phoneNumber,
          'salesforceObject': 'Lead',
          'searchIn': 'PHONE'
      };
    salesforce.searchObject('https://eu26.salesforce.com', accessToken, searchParams, function(result) {
      if (result.searchRecords[0].Id) {
          leadId = result.searchRecords[0].Id;
        vcc.setFieldValue('salesforce_id', result.searchRecords[0].Id);
        vcc.goNext();
      }
    
    });

  });
}

$().onLoad = function() {
  const phone = vcc.getFieldValue('phone1')
  showLeadInSalesforce(phone);
};

There are no comments yet.
Subscribe to our newsletter
or Contact us!
Please note that by subscribing to our newsletter, you agree to receive regular email messages from VCC Live® about service related news and updates. By subscribing to our newsletter, you also agree that VCC Live® will use your data in accordance with the applicable Privacy Policy until you unsubscribe from the newsletter.