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
Nico WrennNico Wrenn 

Setting Pre-Chat Form Fields to Automatically Populate for logged in users

I am working on deploying Snap-Ins chat to our website, including within our web-app and I want to be able to pass values from our logged in users into pre-chat fields in Live Agent. I found this documentation and pasted the code from the article in as a test in our sandbox, but when I do that the chat button goes away, so I can't even get to the pre-chat form.

Help article: https://developer.salesforce.com/docs/atlas.en-us.snapins_web_dev.meta/snapins_web_dev/snapins_web_populate_prechat.htm

All I'm doing is going to the chat button code, un-commenting the embedded_svc.settings.prepopulatedPrechatFields" line, and pasting in the following below it:
embedded_svc.settings.prepopulatedPrechatFields = {
FirstName: “John”,
LastName: “Doe”,
Email: “john.doe@salesforce.com”,
Subject: “Hello” };

Any help is much appreciated.
Niran NSNiran NS
Hi Nico
The reason is pure syntax issue. Please replace double quotes with single quotes. Let me know if you face any issues.
embedded_svc.settings.prepopulatedPrechatFields = {
FirstName: 'John',
LastName: 'Doe',
Email: 'john.doe@salesforce.com',
Subject: 'Hello'};
SandeepSandeep
Hi @Nico Wrenn , We are also trying to do the same, any luck for you? Help is greatly appreciated. 
Thanks,
Sandeep
Adi VagicherlaAdi Vagicherla
@sandeeo, try what Niran had posted. Change the double quotes to Single quotes and test. Also, make sure that you have an agent who is online as it is Pre-Chat form.