function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ian Fisher 15Ian Fisher 15 

How to make fields readonly in Chat SnapIn in Customer Community?

We are using the out-of-the-box Embedded Service Chat SnapIn for Customer Community. Currently, we have configured the SnapIn to show the First Name, Last Name, Email Address and Subject Line.   The First Name, Last Name and Email Address fields are preloaded in the SnapIn when the customer initiates a chat.  We do this by clicking the "Fill in pre-chat fields" setting in the SnapIn component that is added to our Community pages.

The problem that we want to solve is to prevent the user from typing over the First Name, Last Name and Email fields because that would prevent a match on the Contact record in Salesforce when the case is created for the chat (i.e. there would be no contact record that is created and hooked into the newly created case).  I have pinged Salesforce about this and they say there is no way that we can make these fields read-only in the SnapIn.

However, I see in some of the articles that I have read on the developer forum that it might be possible (for example: https://developer.salesforce.com/docs/atlas.en-us.snapins_web_dev.meta/snapins_web_dev/snapins_web_lightning_components_prechat_sample_aura.htm).

So far, I have tried the following with no success:

- Created a Javascript snippet file composed of the following code:

embedded_svc.settings.extraPrechatInfo = [{
      "entityFieldMaps": [{
        "doCreate": true,
        "doFind": false,
        "fieldName": "LastName",
        "isExactMatch": false,
        "label": "Last Name",
    "readOnly": true
      }, {
        "doCreate": true,
        "doFind": false,
        "fieldName": "FirstName",
        "isExactMatch": false,
        "label": "First Name",
    "readOnly": true
      }, {
        "doCreate": true,
        "doFind": true,
        "fieldName": "Email",
        "isExactMatch": true,
        "label": "Email",
    "readOnly": true
      }],
      "entityName": "Contact",
      "saveToTranscript": "Contact",
      "showOnCreate": true
    }];

- Created a Static Resource in Salesforce and loaded the above snippet file into that resource.

- In my SnapIn on the Community page, I have entered the name of the snippet file in the "Snippet Settings File" field of the SnapIn component.

However, the fields are still editable for the user when they start the chat.

Am I missing something, or is this not possible?  TIA.

Ian
Tharun Kumar dontha 22Tharun Kumar dontha 22

Hey,

You cannot use 'readOnly' property over here, since property functionality isn't developed on backend 

Below is the link for your reference

https://developer.salesforce.com/docs/atlas.en-us.snapins_web_dev.meta/snapins_web_dev/snapins_web_prechat_details.htm

Alternate Solution : Create a custom component for PreChat in Embeded Service Deployment 

Ian Fisher 15Ian Fisher 15
Thanks for the feedback, Tharun.