Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
Customize Synced Contact Record Fields Using CTRDataSyncFunction
The CTRDataSyncFunction Lambda documentation lists all the fields that are automatically synced with a VoiceCall record. Use these instructions to sync more fields.
- In your Salesforce org, create a custom field on the VoiceCall object for the desired attribute in the CTR data model.
-
In Amazon Connect, select the CTRDataSyncFunction Lambda function. From the menu select so that you can get access to the function source code. If you
already have the source code for this function, you don’t need to perform this
step.

-
In the utils.js file for the
CTRDataSyncFunction Lambda, update the end of the transformCTR(ctr)
function (where there’s a comment to Add custom fields
here).
1// Check if there are custom contact attributes 2if (ctr.Attributes) { 3 let callAttributes = {}; 4 5 // Get contact attributes data into call attributes 6 callAttributes = getCallAttributes(ctr.Attributes); 7 8 // Add custom fields here ← ADD YOUR CODE HERE!!! 9 10 voiceCall.callAttributes = JSON.stringify(callAttributes); 11} 12...In that location, you can add any custom attributes to the callAttributes object. Add this code before the JSON.stringify(callAttributes) line. Your custom attributes are synced along with the automatically-synced attributes. The following example adds two fields to the list of synced fields:
1// Check if there are custom contact attributes 2if (ctr.Attributes) { 3 let callAttributes = {}; 4 5 // Get contact attributes data into call attributes 6 callAttributes = getCallAttributes(ctr.Attributes); 7 8 // Add custom fields here 9 10 // Custom field from ctr.Attributes 11 if (ctr.Attributes.ConnectionAttempts) { 12 callAttributes.ConnectionAttempts__c = ctr.Attributes.ConnectionAttempts; 13 } 14 // Custom field in ctr (but not in ctr.Attributes) 15 if (ctr.DisconnectReason) { 16 callAttributes.DisconnectReason__c = ctr.DisconnectReason; 17 } 18 19 voiceCall.callAttributes = JSON.stringify(callAttributes); 20} 21... -
Deploy the new version of the Lambda function in your Amazon Connect instance.
To learn more about managing Lambda function versions, see Lambda function versions in the AWS Lambda Developer Guide.