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 table map feature of the Perspectium 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. Here's how: - Create a new custom field in Salesforce on the table where you want to coalesce on an External ID field. Make sure to select the Text field option and check the box next to External ID labelled Set this field as the unique record identified from an external system.
- In the Perspectium application, navigate to your outbound messages to salesforce. 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 |
- Create a field map in ServiceNow to target each of the above attributes, since it supports creating attributes in the outbound message.
Here's an example to Illustrate: ![](/download/attachments/104202293/servicenow_salesforce_external_id_outbound_message.png?version=1&modificationDate=1705385878000&api=v2)
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. Here's how the table field map would look for the ExternalIDField attribute: ![](/download/attachments/104202293/servicenow_salesforce_external_id_table_field_maps.png?version=1&modificationDate=1705385878000&api=v2)
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.
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. |
|