Filter Contacts with Record Type for doCreate in Salesforce Chat

Filter Contacts with Record Type for doCreate in Salesforce Chat

1. Please check the following if you are not aware of using Static Resource in the Experience Cloud Site for Embedded Service Chat.

2. Use the following JavaScript code for the Static Resource JavaScript file.

window._snapinsSnippetSettingsFile = ( function() {
	
	console.log(
		"Snippet settings file loaded."
	);
	
	embedded_svc.settings.extraPrechatFormDetails = [
		{
		  "label": "RecordTypeId",
		  "value": "0125f0000015OI9",
		  "displayToAgent": false
		}
	];

	embedded_svc.snippetSettingsFile.extraPrechatInfo = [
		{
			"entityName": "Contact",
			"showOnCreate": true,
			"linkToEntityName": "Case",
			"linkToEntityField": "ContactId",
			"saveToTranscript": "ContactId",
			"entityFieldMaps" : [
				{
					"doCreate": true,
					"doFind": true,
					"fieldName": "FirstName",
					"isExactMatch": true,
					"label": "First Name"
				}, {
					"doCreate": true,
					"doFind": true,
					"fieldName": "LastName",
					"isExactMatch": true,
					"label": "Last Name"
				}, {
					"doCreate": true,
					"doFind": true,
					"fieldName": "Email",
					"isExactMatch": true,
					"label": "Email"
				}, {
					"doCreate": true,
					"doFind": true,
					"fieldName": "RecordTypeId",
					"isExactMatch": true,
					"label": "RecordTypeId"
				}
			]
		}, 
		{
			"entityName": "Case",
			"showOnCreate": true,
			"saveToTranscript": "CaseId",
			"entityFieldMaps": [ 
				{
					"isExactMatch": false,
					"fieldName": "Subject",
					"doCreate": true,
					"doFind": false,
					"label": "Issue"
				}, {
					"isExactMatch": false,
					"fieldName": "Status",
					"doCreate": true,
					"doFind": false,
					"label": "Status"
				}
			]
		}
	];
	
})();

In the embedded_svc.settings.extraPrechatFormDetails, Record Type Id value is hard coded. In the doCreate, we are using it for filtering or searching the Contacts.

Leave a Reply