User Tools

Site Tools


salesforce_coalesce_external_id

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

salesforce_coalesce_external_id [2017/12/28 21:55]
paul created
salesforce_coalesce_external_id [2017/12/28 22:39] (current)
paul
Line 1: Line 1:
 ====== Coalesce on an External ID Field ====== ====== Coalesce on an External ID Field ======
 +By default, records subscribed into Salesforce will coalesce on the Id field to determine if we should insert a new record or update a current record. ​ So in most cases, you will want to create JSON messages to be consumed into Salesforce with the record'​s Id as found in Salesforce.
  
 +For example, if you are replicating records between ServiceNow and Salesforce, you can use the [[snc_table_maps|table map]] feature of the Perspectium Replicator ServiceNow application to map out a field that holds the record'​s Salesforce Id.  This Id field will generally be saved as the correlation_id field in ServiceNow tables. ​ That way when the record is subscribed into Salesforce, it can use this Id field to find the record and update or insert as appropriate.
  
 +However there may be cases where you want records in Salesforce to coalesce on an External ID field (such as when you want Salesforce to coalesce on the replicated record'​s ServiceNow sys_id) since records may generally be created on another platform like ServiceNow versus starting in Salesforce. ​ Another reason is you may prefer to have more control in the ServiceNow app and have it be your central location for all data transformation and thus want to control coalescing there as well.
 +
 +To set this up, do the following:​\\
 +1) Create a new [[https://​help.salesforce.com/​articleView?​id=adding_fields.htm&​type=5|custom field]] on the table in Salesforce where you want to coalesce on an External ID field. ​ Select the field as a "​Text"​ field and choose the "​External ID" option:
 +{{:​salesforce_custom_external_id_field.png|}}
 +\\
 +\\
 +2) In Perspectium messages sent to Salesforce, you will want to add "​ExternalIDField"​ and "​ExternalIDValue"​ attributes so that when the message is received in Salesforce, it knows what the name of the external ID field is and what value to query for:
 +^ Attribute Name ^ Description|
 +|ExternalIDField|The name of the External ID field in Salesforce as created in step 1|
 +|ExternalIDValue ​  |A record'​s external ID value that we will use to query for in Salesforce in the External ID field |
 +
 +{{::​servicenow_salesforce_external_id_outbound_message.png|}}
 +
 +Using the above example, when the message is subscribed into Salesforce, the app will query the Case table and look for a record with ExternalID__c = '​f4e2e6104f120300b6a444b18110c726'​ and if it finds a record as such, use that record to update.
 +
 +For ServiceNow to Salesforce, you will want to use the [[snc_table_maps#​adding_to_the_attributes|table map]] feature since it supports creating attributes in the outbound message. ​ You can create a field map to target each of the above attributes:
 +{{:​servicenow_salesforce_external_id_table_field_maps.png|}}
 +
 +In this example, the ExternalIdField is scripted to always use the same value since the custom External ID field in Salesforce will always be the same field name while the record'​s sys_id is used for the External ID field'​s value.
 +
 +<WRAP round info>
 +The Salesforce app will automatically query for the specified External ID field and value if both attributes exist; otherwise it will coalesce by the Id field with its normal default behavior.
 +</​WRAP>​
salesforce_coalesce_external_id.txt ยท Last modified: 2017/12/28 22:39 by paul