CRM Data Enrichment with Salesforce
Enrich Salesforce CRM data using CustomJS and dynamic forms.
[Read more]// salesforce
To access the Salesforce API via JavaScript functions you have to complete the following steps. Below you will also find some code examples. You can also find these examples as a template when creating a new function in CustomJS. By the way, here you can get a Salesforce Trial version with which you can also test the API integration: Salesforce Developer Edition Signup

const axios = require('axios');
const instanceUrl = 'https://XYZSSDD-dev-ed.develop.my.salesforce.com';
const apiVersion = '61.0';
const accessToken = await getAccessToken();
await updateOpportunityField(accessToken, 'NextStep', 'Buy CustomJS');
/////////////
async function getAccessToken() {
const tokenUrl = 'https://login.salesforce.com/services/oauth2/token';
try {
const response = await axios.post(tokenUrl, null, {
params: {
grant_type: 'password',
client_id: variables.consumerKey,
client_secret: variables.consumerSecret,
username: variables.username,
password: variables.password + variables.securityToken
}
});
return response.data.access_token;
} catch (error) {
console.log('Error getting access token', error.response.data);
throw error;
}
}
async function updateOpportunityField(accessToken, fieldName, fieldValue) {
try {
await axios.patch(
`${instanceUrl}/services/data/v${apiVersion}/sobjects/Opportunity/${input.opportunityId}`,
{ [fieldName]: fieldValue },
{
headers: {
Authorization: `Bearer ${accessToken}`,
'Content-Type': 'application/json'
}
}
);
} catch (error) {
console.log('Error updating opportunity', error);
throw error;
}
}

Enrich Salesforce CRM data using CustomJS and dynamic forms.
[Read more]Learn how to automate emails using CustomJS with Salesforce integration.
[Read more]Learn how to automate invoices using CustomJS with Salesforce integration.
[Read more]