Recent searches


No recent searches

How to autofill custom field with widget api



Posted Jun 03, 2024

I would like to ask for advice on a technical matter, and would appreciate your help if you have knowledge of it.
What we would like to do is here


When a customer makes an inquiry from a product, we would like to autofill the inquiry field with the account data of the customer who is logged in to the product at the same time he/she clicks on the inquiry widget.


- Name
- Email address
- Custom fields (company name and branch name)

I am able to take over the name and email address, but I am unable to take over the values of the custom fields.

I am using the widget api to autofill the name and email address in the following way.
 

zE(function() {
zE.identify({

email: 'john@example.com',.
});
 

I was also trying to autofill custom fields with custom field IDs as follows, but the situation is not working.


zE(function() {
zE.identify({
name: 'John Citizen',
email: 'john@example.com',.
'123123123123': 'Custom Fold 1'
});
 

I contacted customer support but did not get a good answer, so if you know of anyone who might be able to help me, I would be glad to hear from them.


0

1

1 comment

image avatar

Jakub

Zendesk Customer Care

Hello,

If you want to prefill custom ticket fields in your Web Widget Classic you can use the prefill method,

For a custom field, specify the custom field's id as the id, ex:

fields: [{ id: 2142225, prefill: { '*': 'My text' } }];


In a script it should be:

<script type="text/javascript">
 zESettings = {
   webWidget: {
     contactForm: {
       fields: [
         { id: 2142225, prefill: { '*': 'My custom field text' } }
       ]
     }
   }
 };
</script>

More can be found here: https://developer.zendesk.com/api-reference/widget/settings/#:~:text=%3E-,fields,-Pre%2Dpopulates%20the

1


Please sign in to leave a comment.

Didn't find what you're looking for?

New post