I used this "tutorial" https://developer.salesforce.com/docs/component-library/bundle/lightningsnapin-base-prechat/documentation to create a custom live chat preChat form. But I couldnt figure out how to populate a custom field on the ChatTranscirpt object using the preChat form. Anybody has an idea on what to add to the code here?

I have seen this documentation https://help.salesforce.com/articleView?id=000349323&language=en_US&mode=1&type=1 but it seems it is not possible to apply it on LWC. In general almost all documentation is either for the "old" chat or for aura components. Seems strange to me as Salesforce tries to migrate everything to LWC.


As far as I know, you cannot populate via LWC any fields that are not populated in the standard if they are not on Leads, Contacts or Cases. You define all fields for LWC to populate declaratively in you Embedded Deployment (Setup -> Embedded Service Deployments -> View -> Edit Chat Settings -> Edit Pre-Chat page). You can add there custom fields, but only if they are on either Lead, Contact or Case, depending on the options you choose (Sales, Service or Contact only). Also, potentially you can modify LWC to ask for additional fields and simply pass it in modified this.fields via this.startChat - but this is a no no, because "You must provide a field array based on the same prechat fields that are defined in setup. Extra or missing fields are not allowed." (https://developer.salesforce.com/docs/component-library/bundle/lightningsnapin-base-prechat/documentation)

As a workaround, if the pre-chat is going to be embedded in 3rd party website, you can try to modify embedded_svc.settings.extraPrechatInfo in the snippet code (https://developer.salesforce.com/docs/atlas.en-us.snapins_web_dev.meta/snapins_web_dev/snapins_web_prechat_details.htm) - it does work with LWC, saving additional fields which are absent in the form. You can either hardcode it in the snippet or have another form on your website, before LWC. However, I know this workaround works for Cases, I don't know if it is valid for ChatTranscript.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.