Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

For a sample proxy service that illustrates how to work with records, see Sample configuration

OperationDescription
createCreates a record in Salesforce.
createMultipleRecordsCreates multiple sObject(s) in Salesforce.
createNestedRecordsCreate nested records for sObjects.
updateUpdates a record in Salesforce.

delete

Deletes a record from Salesforce.
recentlyViewedItemRetrieves the recently viewed item in Salesforce.
retrieveFieldValuesRetrieves specific field values for a specific sObject.
upsertCreates or updates (
upsets
upserts) a record using external ID.

Operation details

This section provides further details on the operations related to Records.

...

Code Block
languagexml
titlecreate
<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.
  • sObjectNameFieldAndValue: The .json format property used to create the record. Include all mandatory fields according to the requirements for the specified sobject. 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 the sObjectName fieldAndValue property would look like this:

    Code Block
    titleSample sObjectName fieldAndValue property
    {
    	"name":"wso2",
    	"description":"This account belongs to WSO2"
    }

...

Code Block
languagexml
titleSample request for 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",
  "sobjectsObjectName":"Account",
  "registryPath": "connectors/SalesforceRest",
  "sObjectNamefieldAndValue": {
    "name": "wso2",
    "description":"This Account belongs to WSO2"
  }
}

...

Code Block
languagexml
titlecreateMultipleRecords
<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.
  • sObjectNamefieldAndValue: The .json format property, which specifies each record as an entry within the records array. Include all mandatory fields according to the requirements for the specified sobject. 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 the sObjectName property the fieldAndValue property might look like this:

    Code Block
    titleSample 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
languagexml
titleSample request for 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",
  "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
languagexml
titlecreateNestedRecords
<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.
  • sObjectNamefieldAndValue: The .json format property, which defines the records. Include all mandatory fields according to the requirements for the specified sobject. For example, if you want to create two new accounts and their child records, the sObjectName property the fieldAndValue property might look like this:

    Code Block
    titleSample 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
languagexml
titleSample request for 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",
  "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
languagexml
titleupdate
<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.
  • sObjectNamefieldAndValue: The json format property with the new definition for the record.
  • Id: The ID of the record you are updating.

...

Code Block
languagexml
titleSample request for 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",
  "sobjectsObjectName":"Account",
  "Id":"00128000002OOhD",
  "registryPath": "connectors/SalesforceRest",
  "sObjectNamefieldAndValue": {
    "name": "wso2",
    "description":"This Account belongs to WSO2"
  }
}

...

Code Block
languagexml
titledelete
<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
languagexml
titleSample request for 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",
  "sobjectsObjectName":"Account",
  "idToDelete":"00128000002OOhD",
  "registryPath": "connectors/SalesforceRest"
 }

...

Code Block
languagexml
titleretrieveFieldValues
<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
languagexml
titleSample request for 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",
  "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
upsert
upsert

...

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
languagexml
titleupsert
<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.
  • sObjectNamefieldAndValue: 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
languagexml
titleSample Request for 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",
  "sobjectsObjectName":"Account",
  "registryPath": "connectors/Salesforcerest",
  "intervalTime" : "2400000",
  "externalIDField":"sample__c",
  "Id":"15222",
  "sObjectNamefieldAndValue": 
  {
      "Name":"hhhhhhhhhhhhhhaaaaaa"
  }
 } 

...

Code Block
languagexml
titleSample Proxy
<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>