• Tharun Kumar dontha 22
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 3
    Replies
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
Hi All,

I want to display number of contacts associated with an account using triggers.

for this I had created a lookup field like noofcontacts__c in account  object. and Wrote code as

trigger numberofcontacts on contact(after insert, after update, after delete) {
    Map<Id, List<Contact>> AcctContactList = new Map<Id, List<Contact>>();
    Set<Id> AcctIds = new Set<Id>();   
    List<schema.Account> AcctList = new List<schema.Account>();
    List<schema.Contact> ConList = new List<schema.Contact>();
   
    if(trigger.isInsert || trigger.isUPdate) {
        for(Contact Con : trigger.New) {
            if(String.isNotBlank(Con.AccountId)){
                AcctIds.add(Con.AccountId); 
            }  
        } 
    }
   
    if(trigger.isDelete) {
        for(Contact Con : trigger.Old) {
            AcctIds.add(Con.AccountId);    
        } 
    }          
   
    if(AcctIds.size() > 0){
        ConList = [SELECT Id, AccountId FROM Contact WHERE AccountId IN : AcctIds];
       
        for(Contact Con : ConList) {
            if(!AcctContactList.containsKey(Con.AccountId)){
                AcctContactList.put(Con.AccountId, new List<Contact>());
            }
            AcctContactList.get(Con.AccountId).add(Con);     
        }                          
      
           
        AcctList = [SELECT noofContacts__c FROM Account WHERE Id IN : AcctIds];
        for(Account Acc : AcctList) {
            List<schema.Contact> ContList = new List<schema.Contact>();
            ContList = AcctContactList.get(Acc.Id);
            Acc.Number_of_Contacts__c = ContList.size();
        }   
       
      
        update AcctList;   
    }

}
 I am   getting an error as "Variable doesnot exist:id".

Kindly support and suggest.

Thanks