searchObject
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);
};
Comments
Can’t find what you need? Use the comment section below to connect with others, get answers from our experts, or share your ideas with us.
There are no comments yet.