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
shajakk kkajshajakk kkaj 

lightning prechat code trying to understand

I'm kinda newbie on js and lightning but i was trying to figure out what this code below is doing. In js a map method runs a function for each item on array but I dont understand why the code is running with a const and getting the field to fillup. 
I also need verify baseprechat's interface to check the method and atributes available but i havent found even though i retrieve all the code to my vscode.
 
import BasePrechat from 'lightningsnapin/basePrechat';
import { api, track } from 'lwc';
import startChatLabel from '@salesforce/label/c.StartChat';

export default class Prechat extends BasePrechat {
    @api prechatFields;
    @api backgroundImgURL;
    @track fields;
    @track namelist;
    startChatLabel;

    /**
     * Set the button label and prepare the prechat fields to be shown in the form.
     */
    connectedCallback() {
        this.startChatLabel = startChatLabel;
        this.fields = this.prechatFields.map(field => {
            const { label, name, value, required, maxLength } = field;

            return { label, value, name, required, maxLength };
        });
        this.namelist = this.fields.map(field => field.name);
    }
}

 
AbhishekAbhishek (Salesforce Developers) 
Hi,

Go through the below articles which might help you understand about lighting pre-chat 

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

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

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

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

Thanks.
seriale onlineseriale online
Based on link 3, it seems like if we were using a Visualforce Page for our Prechat form, we would be able to upsert a single Contact record, in order to associate the LiveChatTranscript to an existing record. However, I'm having a hard time hunting down how that would be done using a custom Lightning Component hooked up to a Snap-in, as described in link 1.
We're trying to do the association based on a Unique External Id field. When an existing value is populated in the Prechat form, no Contact record is created nor associated to the LiveChatTranscript. watch your favourite show on pinoy1tv (https://pinoychannel.cc/) When a new value is populated, a new Contact is created and associated. The behavior observed so far seems to indicate any DML failures are silent, and the transcript record can be created regardless of any failures up to that point.
I can't find any documentation on the Prechat API surfaced via the lightningsnapin:prechatAPI component. It doesn't seem to have any sort of analogue to the findOrCreate map that would have allowed us to upsert in classic.
Is it possible to have a Lightning Prechat Snap-in upsert a Contact record based on a Unique External Id field included in the prechat form? If so, how?