0

Biggest thing first I am not much of a developer but more an admin, my team is working on passing through a specific visitors UUID from our webpage into salesforce. We are looking to have this UUID passed into the Prechat form details and saved on the Chat Visitor record once the chat finishes. We have our script with extra prechat info but we are not seeing this actually save in salesforce once the chat finishes. does anyone see where we may be going wrong?

JavaScript

    var initESW = function(gslbBaseURL) {
        embedded_svc.settings.displayHelpButton = true; //Or false
        embedded_svc.settings.language = ''; //For example, enter 'en' or 'en-US'
        embedded_svc.settings.enabledFeatures = ['LiveAgent'];
        embedded_svc.settings.entryFeature = 'LiveAgent';
        
        embedded_svc.settings.extraPreChatFormDetails = [
            {
                "label": "Participant Account UUID",
                "value": "{$uuid}",
                "displayToAgent": true
            }
        ];
        embedded_svc.settings.extraPrechatInfo = [{
            "entityFieldMaps": [{
                "doCreate": true,
                "doFind": true,
                "fieldName": "Participant_Account_UUID__c",
                "isExactMatch": true,
                "label": "Participant Account UUID"
            }],
            "entityName": "LiveChatVisitor"
        }];
        embedded_svc.init(
            'https://benefitresource--service.my.salesforce.com',
            'https://service-bri.cs9.force.com/test',
            gslbBaseURL,
            '00DK000000WfuyF',
            'BRI_Chat',
            {
                baseLiveAgentContentURL: 'https://c.la3-c1cs-dfw.salesforceliveagent.com/content',
                deploymentId: '572K000000002Di',
                buttonId: '573K000000002n5',
                baseLiveAgentURL: 'https://d.la3-c1cs-dfw.salesforceliveagent.com/chat',
                eswLiveAgentDevName: 'BRI_Chat',
                isOfflineSupportEnabled: true
            }
        );
    };
    if (!window.embedded_svc) {
        var s = document.createElement('script');
        s.setAttribute('src', 'https://benefitresource--service.my.salesforce.com/embeddedservice/5.0/esw.min.js');
        s.onload = function() {
            initESW(null);
        };
        document.body.appendChild(s);
    } else {
        initESW('https://service.force.com');
    }
1
  • Also having a similar issue but with live chat implementation using the mobile SDK (our web version is working fine). Will be interested to see the responses. Commented Dec 3, 2020 at 10:49

1 Answer 1

0

I believe the issue is that your FindOrCreate object in your extraPrechatInfo is referencing a LiveChatVisitor record, which is not supported by the FindOrCreate API. The objects associated with the chat at runtime (LiveChatTranscript, LiveChatVisitor, LiveAgentSession) are managed separately, and can't be manipulated with the FindOrCreate API.

You can use your extraPreChatFormDetails object to write to a custom field on your chat transcript, and then use a custom lookup field on the LiveChatVisitor record to complete your use case.

 // writes to the custom field Participant_Account_UUID__c on LiveChatTranscript
  embedded_svc.settings.extraPreChatFormDetails = [
            {
                "label": "Participant Account UUID",
                "value": "{$uuid}",
                "displayToAgent": true,
                "transcriptFields" : ["Participant_Account_UUID__c"]
            }
        ];

Alternatively, you can use an Apex Trigger or an autolaunched flow on LiveChatTranscript to reference the LiveChatVisitorID field to get the LiveChatVisitor record, and then do your field update from there.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .