Overview
The following operations allow you to work with Records. A Record is an instance of a particular sObject. Click an operation name to see details on how to use it.
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 | upserts a new record using external ID. |
Operation details
This section provides further details on the operations related to Records.
Creating a record for a specific sObject
To create a record, use salesforcerest.create
and specify the following properties.
<salesforcerest.create> <sobject>{$ctx:sobject}</sobject> <sObjectName>{$ctx:sObjectName}</sObjectName> </salesforcerest.create>
Properties
sobject
: The type of object for which you will create a record.sObjectName
: 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
property would look like this:Sample sObjectName property{ "name":"wso2", "description":"This account belongs to WSO2" }
Sample request
Following is a sample REST request that can be handled by the create
operation.
{ "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", "sobject":"Account", "registryPath": "connectors/SalesforceRest", "sObjectName": { "name": "wso2", "description":"This Account belongs to WSO2" } }
Related Salesforce REST documentation
https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_sobject_create.htm
Creating multiple records
To create multiple records of the same sObject type, use salesforcerest.createMultipleRecords
and specify the following properties.
<salesforcerest.createMultipleRecords> <sobject>{$ctx:sobject}</sobject> <sObjectName>{$ctx:sObjectName}</sObjectName> </salesforcerest.createMultipleRecords>
Properties
sobject
: The object type for which you are creating records.sObjectName
: 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 might look like this:Sample sObjectName 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" }] }
Sample request
Following is a sample REST request that can be handled by the createMultipleRecords
operation.
{ "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", "sobject":"Account", "registryPath": "connectors/SalesforceRest", "sObjectName": { "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" }] } }
Related Salesforce REST documentation
Creating nested records
To create nested records for a specific sObject, use salesforcerest.createNestedRecords
and specify the following properties.
<salesforcerest.createNestedRecords> <sobject>{$ctx:sobject}</sobject> <sObjectName>{$ctx:sObjectName}</sObjectName> </salesforcerest.createNestedRecords>
Properties
sobject
: The object type of the top-level records you are creating.sObjectName
: 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 might look like this:Sample sObjectName 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" }] } }] }
Sample request
Following is a sample REST request that can be handled by the createNestedRecords
operation.
{ "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", "sobject":"Account", "registryPath": "connectors/SalesforceRest", "sObjectName": { "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" }] } }] } }
Related Salesforce REST documentation
Updating a record
To update a record, use salesforcerest.update
and specify the following properties.
<salesforcerest.update> <sobject>{$ctx:sobject}</sobject> <sObjectName>{$ctx:sObjectName}</sObjectName> <Id>{$ctx:Id}</Id> </salesforcerest.update>
Properties
sobject
: The object type of the record.sObjectName
: The json format property with the new definition for the record.Id
: The ID of the record you are updating.
Sample request
Following is a sample REST request that can be handled by the update
operation.
{ "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", "sobject":"Account", "Id":"00128000002OOhD", "registryPath": "connectors/SalesforceRest", "sObjectName": { "name": "wso2", "description":"This Account belongs to WSO2" } }
Related Salesforce REST documentation
https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_update_fields.htm
Deleting a record
To delete a record, use salesforcerest.delete
and specify the following properties.
<salesforcerest.delete> <sobject>{$ctx:sobject}</sobject> <idToDelete>{$ctx:idToDelete}</idToDelete> </salesforcerest.delete>
Properties
sobject
: The object type of the record.idToDelete
: The ID of the record you want to delete.
Sample request
Following is a sample REST request that can be handled by the delete
operation.
{ "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", "sobject":"Account", "idToDelete":"00128000002OOhD", "registryPath": "connectors/SalesforceRest" }
Related Salesforce REST documentation
https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_delete_record.htm
Retrieving the recently viewed items
To retrieve the recently viewed items, use salesforcerest.recentlyViewedItem
and specify the following properties.
<salesforcerest.recentlyViewedItem> <limit>{$ctx:limit}</limit> </salesforcerest.recentlyViewedItem>
Properties
limit
: The maximum number of records to be returned.
Sample request
Following is a sample REST request that can be handled by the recentlyViewedItem
operation.
{ "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", "limit":"5", "registryPath": "connectors/SalesforceRest" }
Related Salesforce REST documentation
https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_recent_items.htm
Retrieving specific field values
To retrieve specific field values for a specific sObject, use salesforcerest.retrieveFieldValues
and specify the following properties.
<salesforcerest.retrieveFieldValues> <sobject>{$ctx:sobject}</sobject> <rowId>{$ctx:rowId}</rowId> <fields>{$ctx:fields}</fields> </salesforcerest.retrieveFieldValues>
Properties
sobject
: 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.
Sample request
Following is a sample REST request that can be handled by the retrieveFieldValues
operation.
{ "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", "sobject": "Account", "rowId":"00128000005YjDnAAK", "fields":"AccountNumber,BillingPostalCode", "registryPath": "connectors/SalesforceRest" }
Related Salesforce REST documentation
https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_get_field_values.htm
Upserting Record using externalId
To upsertingrecord by using externalId, use salesforcerest.upsert
and specify the following properties. This method is used to create records or update existing records (upsert) based on the value of a
specified external ID field.
- If the specified value doesn't exist, a new record is created.
- If a record does exist with that value, the field values specified in the request body are updated.
<salesforcerest.upsert> <sobject>{$ctx:sobject}</sobject> <externalIDField>{$ctx:externalIDField}</externalIDField> <Id>{$ctx:Id}</Id> <sObjectName>{$ctx:sObjectName}</sObjectName> </salesforcerest.upsert>
Properties
sobject
: The object type of the record.- externalIDField: The external Id Field of the sobject.
- Id: The value of the customExtIdField.
sObjectName: 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.
{ "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", "sobject":"Account", "registryPath": "connectors/Salesforcerest", "intervalTime" : "2400000", "externalIDField":"sample__c", "Id":"15222", "sObjectName": { "Name":"hhhhhhhhhhhhhhaaaaaa" } }
Related Salesforce REST documentation
https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_upsert.htm
Sample configuration
Following is a sample proxy service that illustrates how to connect to Salesforce with the init
operation and use the create
operation. The sample request for this proxy can be found in the create
sample request.
<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="sobject" expression="json-eval($.sobject)"/> <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>{$ctx:sobject}</sobject> <sObjectName>{$ctx:sObjectName}</sObjectName> </salesforcerest.create> <send/> </inSequence> </target> <description/> </proxy>