...
For a sample proxy service that illustrates how to work with records, see Sample configuration.
Operation | Description |
---|---|
create | Creates a record in Salesforce. |
createMultipleRecords | Creates multiple sObject(s) in Salesforce. |
createNestedRecords | Create nested records for sObjects. |
update | Updates a record in Salesforce. |
Deletes a record from Salesforce. | |
recentlyViewedItem | Retrieves the recently viewed item in Salesforce. |
retrieveFieldValues | Retrieves specific field values for a specific sObject. |
upsert | Creates or updates ( |
upserts) a record using external ID. |
Operation details
This section provides further details on the operations related to Records.
...
Code Block | ||||
---|---|---|---|---|
| ||||
<salesforcerest.create> <sobject><sObjectName>{$ctx:sobjectsObjectName}</sobject>sObjectName> <sObjectName><fieldAndValue>{$ctx:sObjectNamefieldAndValue}</sObjectName>fieldAndValue> </salesforcerest.create> |
Properties
sobject
sObjectName: The type of object for which you will create a record.
sObjectName
FieldAndValue
: The .json format property used to create the record. Include all mandatory fields according to the requirements for the specifiedsobject
. For example, if you are creating a record for the Account sObject, "name" is a mandatory parameter, and you might want to include the optional description, so thesObjectName
fieldAndValue property would look like this:Code Block title Sample sObjectName fieldAndValue property { "name":"wso2", "description":"This account belongs to WSO2" }
...
Code Block | ||||
---|---|---|---|---|
| ||||
{ "accessToken":"00D280000017q6q!AQoAQOeXcp7zKo3gUdy6r064_LsJ5bYYrUn_qAZG9TtKFLPfUMRxiato.E162_2XAtCTZLFQTbNk2Rz6Zm_juSakFE_aaBPp", "apiUrl":"https://ap2.salesforce.com", "clientId": "3MVG9ZL0ppGP5UrBrnsanGUZRgHqc8gTV4t_6tfuef8Zz4LhFPipmlooU6GBszpplbTzVXXWjqkGHubhRip1s", "refreshToken": "5Aep861TSESvWeug_xvFHRBTTbf_YrTWgEyjBJo7Xr34yOQ7GCFUN5DnNPxzDIoGoWi4evqOl_lT1B9nE5dAtSb", "clientSecret": "9104967092887676680", "hostName": "https://login.salesforce.com", "intervalTime" : "100000", "apiVersion": "v32.0", "sobjectsObjectName":"Account", "registryPath": "connectors/SalesforceRest", "sObjectNamefieldAndValue": { "name": "wso2", "description":"This Account belongs to WSO2" } } |
...
Code Block | ||||
---|---|---|---|---|
| ||||
<salesforcerest.createMultipleRecords> <sobject><sObjectName>{$ctx:sobjectsObjectName}</sobject>sObjectName> <sObjectName><fieldAndValue>{$ctx:sObjectNamefieldAndValue}</sObjectName>fieldAndValue> </salesforcerest.createMultipleRecords> |
Properties
sobject
sObjectName: The object type for which you are creating records.
sObjectName
fieldAndValue
: The .json format property, which specifies each record as an entry within therecords
array. Include all mandatory fields according to the requirements for the specifiedsobject
. For example, if you are creating records for the Account sObject, "name" is a mandatory parameter, and you might want to include additional optional values for each record, so thesObjectName
property the fieldAndValue property might look like this:Code Block title Sample sObjectName fieldAndValue property { "records": [ { "attributes": {"type": "Account", "referenceId": "ref1"}, "name": "wso2", "phone": "1111111", "website": "www.salesforce1.com" }, { "attributes": {"type": "Account", "referenceId": "ref2"}, "name": "slwso2", "phone": "22222222", "website": "www.salesforce2.com" }] }
...
Code Block | ||||
---|---|---|---|---|
| ||||
{ "accessToken":"00D280000017q6q!AQoAQOeXcp7zKo3gUdy6r064_LsJ5bYYrUn_qAZG9TtKFLPfUMRxiato.E162_2XAtCTZLFQTbNk2Rz6Zm_juSakFE_aaBPp", "apiUrl":"https://ap2.salesforce.com", "clientId": "3MVG9ZL0ppGP5UrBrnsanGUZRgHqc8gTV4t_6tfuef8Zz4LhFPipmlooU6GBszpplbTzVXXWjqkGHubhRip1s", "refreshToken": "5Aep861TSESvWeug_xvFHRBTTbf_YrTWgEyjBJo7Xr34yOQ7GCFUN5DnNPxzDIoGoWi4evqOl_lT1B9nE5dAtSb", "clientSecret": "9104967092887676680", "hostName": "https://login.salesforce.com", "apiVersion": "v32.0", "intervalTime" : "100000", "sobjectsObjectName":"Account", "registryPath": "connectors/SalesforceRest", "sObjectNamefieldAndValue": { "records": [ { "attributes": {"type": "Account", "referenceId": "ref1"}, "name": "wso2", "phone": "1111111", "website": "www.salesforce1.com" }, { "attributes": {"type": "Account", "referenceId": "ref2"}, "name": "slwso2", "phone": "22222222", "website": "www.salesforce2.com" }] } } |
...
Code Block | ||||
---|---|---|---|---|
| ||||
<salesforcerest.createNestedRecords> <sobject><sObjectName>{$ctx:sobjectsObjectName}</sobject> <sObjectName><fieldAndValue>{$ctx:sObjectNamefieldAndValue}</sObjectName>fieldAndValue> </salesforcerest.createNestedRecords> |
Properties
sobject
sObjectName: The object type of the top-level records you are creating.
sObjectName
fieldAndValue
: The .json format property, which defines the records. Include all mandatory fields according to the requirements for the specifiedsobject
. For example, if you want to create two new accounts and their child records, thesObjectName
property the fieldAndValue property might look like this:Code Block title Sample sObjectName fieldAndValue property { "records" :[{ "attributes" : {"type" : "Account", "referenceId" : "ref1"}, "name" : "SampleAccount1", "phone" : "1234567890", "website" : "www.salesforce.com", "numberOfEmployees" : "100", "type" : "Analyst", "industry" : "Banking", "Contacts" : { "records" : [{ "attributes" : {"type" : "Contact", "referenceId" : "ref2"}, "lastname" : "Smith", "Title" : "President", "email" : "sample@salesforce.com" },{ "attributes" : {"type" : "Contact", "referenceId" : "ref3"}, "lastname" : "Evans", "title" : "Vice President", "email" : "sample@salesforce.com" }] } },{ "attributes" : {"type" : "Account", "referenceId" : "ref4"}, "name" : "SampleAccount2", "phone" : "1234567890", "website" : "www.salesforce.com", "numberOfEmployees" : "52000", "type" : "Analyst", "industry" : "Banking", "childAccounts" : { "records" : [{ "attributes" : {"type" : "Account", "referenceId" : "ref5"}, "name" : "SampleChildAccount1", "phone" : "1234567890", "website" : "www.salesforce.com", "numberOfEmployees" : "100", "type" : "Analyst", "industry" : "Banking" }] }, "Contacts" : { "records" : [{ "attributes" : {"type" : "Contact", "referenceId" : "ref6"}, "lastname" : "Jones", "title" : "President", "email" : "sample@salesforce.com" }] } }] }
...
Code Block | ||||
---|---|---|---|---|
| ||||
{ "accessToken":"00D280000017q6q!AQoAQOeXcp7zKo3gUdy6r064_LsJ5bYYrUn_qAZG9TtKFLPfUMRxiato.E162_2XAtCTZLFQTbNk2Rz6Zm_juSakFE_aaBPp", "apiUrl":"https://ap2.salesforce.com", "clientId": "3MVG9ZL0ppGP5UrBrnsanGUZRgHqc8gTV4t_6tfuef8Zz4LhFPipmlooU6GBszpplbTzVXXWjqkGHubhRip1s", "refreshToken": "5Aep861TSESvWeug_xvFHRBTTbf_YrTWgEyjBJo7Xr34yOQ7GCFUN5DnNPxzDIoGoWi4evqOl_lT1B9nE5dAtSb", "clientSecret": "9104967092887676680", "hostName": "https://login.salesforce.com", "intervalTime" : "100000", "apiVersion": "v32.0", "sobjectsObjectName":"Account", "registryPath": "connectors/SalesforceRest", "sObjectNamefieldAndValue": { "records" :[{ "attributes" : {"type" : "Account", "referenceId" : "ref1"}, "name" : "SampleAccount1", "phone" : "1234567890", "website" : "www.salesforce.com", "numberOfEmployees" : "100", "type" : "Analyst", "industry" : "Banking", "Contacts" : { "records" : [{ "attributes" : {"type" : "Contact", "referenceId" : "ref2"}, "lastname" : "Smith", "Title" : "President", "email" : "sample@salesforce.com" },{ "attributes" : {"type" : "Account", "referenceId" : "ref3"}, "lastname" : "Evans", "title" : "Vice President", "email" : "sample@salesforce.com" }] } },{ "attributes" : {"type" : "Account", "referenceId" : "ref4"}, "name" : "SampleAccount2", "phone" : "1234567890", "website" : "www.salesforce.com", "numberOfEmployees" : "52000", "type" : "Analyst", "industry" : "Banking", "childAccounts" : { "records" : [{ "attributes" : {"type" : "Account", "referenceId" : "ref5"}, "name" : "SampleChildAccount1", "phone" : "1234567890", "website" : "www.salesforce.com", "numberOfEmployees" : "100", "type" : "Analyst", "industry" : "Banking" }] }, "Contacts" : { "records" : [{ "attributes" : {"type" : "Contact", "referenceId" : "ref6"}, "lastname" : "Jones", "title" : "President", "email" : "sample@salesforce.com" }] } }] } } |
...
Code Block | ||||
---|---|---|---|---|
| ||||
<salesforcerest.update> <sobject><sObjectName>{$ctx:sobjectsObjectName}</sobject>sObjectName> <sObjectName><fieldAndValue>{$ctx:sObjectNamefieldAndValue}</sObjectName>fieldAndValue> <Id>{$ctx:Id}</Id> </salesforcerest.update> |
Properties
sobject
sObjectName: The object type of the record.
sObjectName
fieldAndValue
: The json format property with the new definition for the record.Id
: The ID of the record you are updating.
...
Code Block | ||||
---|---|---|---|---|
| ||||
{ "accessToken":"00D280000017q6q!AQoAQOeXcp7zKo3gUdy6r064_LsJ5bYYrUn_qAZG9TtKFLPfUMRxiato.E162_2XAtCTZLFQTbNk2Rz6Zm_juSakFE_aaBPp", "apiUrl":"https://ap2.salesforce.com", "clientId": "3MVG9ZL0ppGP5UrBrnsanGUZRgHqc8gTV4t_6tfuef8Zz4LhFPipmlooU6GBszpplbTzVXXWjqkGHubhRip1s", "refreshToken": "5Aep861TSESvWeug_xvFHRBTTbf_YrTWgEyjBJo7Xr34yOQ7GCFUN5DnNPxzDIoGoWi4evqOl_lT1B9nE5dAtSb", "clientSecret": "9104967092887676680", "hostName": "https://login.salesforce.com", "intervalTime" : "100000", "apiVersion": "v32.0", "sobjectsObjectName":"Account", "Id":"00128000002OOhD", "registryPath": "connectors/SalesforceRest", "sObjectNamefieldAndValue": { "name": "wso2", "description":"This Account belongs to WSO2" } } |
...
Code Block | ||||
---|---|---|---|---|
| ||||
<salesforcerest.delete> <sobject><sObjectName>{$ctx:sobjectsObjectName}</sobject>sObjectName> <idToDelete>{$ctx:idToDelete}</idToDelete> </salesforcerest.delete> |
Properties
sobject
sObjectName: The object type of the record.
idToDelete
: The ID of the record you want to delete.
...
Code Block | ||||
---|---|---|---|---|
| ||||
{ "accessToken":"00D280000017q6q!AQoAQOeXcp7zKo3gUdy6r064_LsJ5bYYrUn_qAZG9TtKFLPfUMRxiato.E162_2XAtCTZLFQTbNk2Rz6Zm_juSakFE_aaBPp", "apiUrl":"https://ap2.salesforce.com", "clientId": "3MVG9ZL0ppGP5UrBrnsanGUZRgHqc8gTV4t_6tfuef8Zz4LhFPipmlooU6GBszpplbTzVXXWjqkGHubhRip1s", "refreshToken": "5Aep861TSESvWeug_xvFHRBTTbf_YrTWgEyjBJo7Xr34yOQ7GCFUN5DnNPxzDIoGoWi4evqOl_lT1B9nE5dAtSb", "clientSecret": "9104967092887676680", "hostName": "https://login.salesforce.com", "intervalTime" : "100000", "apiVersion": "v32.0", "sobjectsObjectName":"Account", "idToDelete":"00128000002OOhD", "registryPath": "connectors/SalesforceRest" } |
...
Code Block | ||||
---|---|---|---|---|
| ||||
<salesforcerest.retrieveFieldValues> <sobject><sObjectName>{$ctx:sobjectsObjectName}</sobject>sObjectName> <rowId>{$ctx:rowId}</rowId> <fields>{$ctx:fields}</fields> </salesforcerest.retrieveFieldValues> |
Properties
sobject
sObjectName: The object type of the record.
- rowId: The ID of the record whose values you want to retrieve.
- fields: A comma-separated list of fields whose values you want to retrieve.
...
Code Block | ||||
---|---|---|---|---|
| ||||
{ "accessToken":"00D280000017q6q!AQoAQOeXcp7zKo3gUdy6r064_LsJ5bYYrUn_qAZG9TtKFLPfUMRxiato.E162_2XAtCTZLFQTbNk2Rz6Zm_juSakFE_aaBPp", "apiUrl":"https://ap2.salesforce.com", "clientId": "3MVG9ZL0ppGP5UrBrnsanGUZRgHqc8gTV4t_6tfuef8Zz4LhFPipmlooU6GBszpplbTzVXXWjqkGHubhRip1s", "refreshToken": "5Aep861TSESvWeug_xvFHRBTTbf_YrTWgEyjBJo7Xr34yOQ7GCFUN5DnNPxzDIoGoWi4evqOl_lT1B9nE5dAtSb", "clientSecret": "9104967092887676680", "hostName": "https://login.salesforce.com", "intervalTime" : "100000", "apiVersion": "v32.0", "sobjectsObjectName": "Account", "rowId":"00128000005YjDnAAK", "fields":"AccountNumber,BillingPostalCode", "registryPath": "connectors/SalesforceRest" } |
...
https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_get_field_values.htm
Anchor | ||||
---|---|---|---|---|
|
...
Upserting a record using an external ID
To create or update (upsetupsert) a record using an external ID, use salesforcerest.upsert
and specify the following properties. This method is used to create records or update existing records based on the value of a specified external ID field.
...
Code Block | ||||
---|---|---|---|---|
| ||||
<salesforcerest.upsert> <sobject><sObjectName>{$ctx:sobjectsObjectName}</sobject>sObjectName> <externalIDField>{$ctx:externalIDField}</externalIDField> <Id>{$ctx:Id}</Id> <sObjectName><fieldAndValue>{$ctx:sObjectNamefieldAndValue}</sObjectName>fieldAndValue> </salesforcerest.upsert> |
Properties
sobject
sObjectName: The object type of the record.
externalIDField
: The external Id Field of the sobjectsubject.Id
: The value of the customExtIdField.- sObjectName
fieldAndValue
: The json format property/payload used to create the record.
Sample request
Following is a sample REST request that can be handled by the upsert
operation.
Code Block | ||||
---|---|---|---|---|
| ||||
{ "accessToken":"00D280000017q6q!AQoAQMMZWoN9MQZcXLW475YYoIdJFUICTjbGh67jEfAeV7Q57Ac2Ov.0ZuM_2Zx6SnrOmwpml8Qf.XclstTQiXtCYSGRBcEv", "apiUrl":"https://ap2.salesforce.com", "clientId": "3MVG9ZL0ppGP5UrBrnsanGUZRgHqc8gTV4t_6tfuef8Zz4LhFPipmlooU6GBszpplbTzVXXWjqkGHubhRip1s", "refreshToken": "5Aep861TSESvWeug_ztpnAk6BGQxRdovMLhHso81iyYKO6hTm68KfebpK7UYtEzF0ku8JCz7CNto8b3YMRmZrhy", "clientSecret": "9104967092887676680", "hostName": "https://login.salesforce.com", "apiVersion": "v32.0", "sobjectsObjectName":"Account", "registryPath": "connectors/Salesforcerest", "intervalTime" : "2400000", "externalIDField":"sample__c", "Id":"15222", "sObjectNamefieldAndValue": { "Name":"hhhhhhhhhhhhhhaaaaaa" } } |
...
Code Block | ||||
---|---|---|---|---|
| ||||
<proxy xmlns="http://ws.apache.org/ns/synapse" name="create" statistics="disable" trace="disable" transports="https http"> <target> <inSequence> <property name="accessToken" expression="json-eval($.accessToken)"/> <property name="apiUrl" expression="json-eval($.apiUrl)"/> <property name="sobjectfieldAndValue" expression="json-eval($.sobjectfieldAndValue)"/> <property name="sObjectName" expression="json-eval($.sObjectName)"/> <property name="clientId" expression="json-eval($.clientId)"/> <property name="refreshToken" expression="json-eval($.refreshToken)"/> <property name="clientSecret" expression="json-eval($.clientSecret)"/> <property name="hostName" expression="json-eval($.hostName)"/> <property name="apiVersion" expression="json-eval($.apiVersion)"/> <property name="registryPath" expression="json-eval($.registryPath)"/> <property name="intervalTime" expression="json-eval($.intervalTime)"/> <salesforcerest.init> <accessToken>{$ctx:accessToken}</accessToken> <apiUrl>{$ctx:apiUrl}</apiUrl> <apiVersion>{$ctx:apiVersion}</apiVersion> <hostName>{$ctx:hostName}</hostName> <clientSecret>{$ctx:clientSecret}</clientSecret> <clientId>{$ctx:clientId}</clientId> <refreshToken>{$ctx:refreshToken}</refreshToken> <registryPath>{$ctx:registryPath}</registryPath> <intervalTime>{$ctx:intervalTime}</intervalTime> </salesforcerest.init> <log category="INFO" level="full" separator=","/> <salesforcerest.create> <sobject><fieldAndValue>{$ctx:sobjectfieldAndValue}</sobject>fieldAndValue> <sObjectName>{$ctx:sObjectName}</sObjectName> </salesforcerest.create> <send/> </inSequence> </target> <description/> </proxy> |