Setting A Custom Field From A URL

Last Updated -

When linking your customers to your support center contact form, chat widget, or email widget, you can pre-fill fields on the form using query strings. A query string is a part of the URL that defines a variable, such as the customer's name. 

By appending a query string to the end of a form URL, you can set case and custom fields when a user submits their case. 

First, however, you'll need to add the field to your form. Read this article for help with that. Here's an example the HTML you'd add to your form for a custom field, where 'keygoeshere' is your custom field's key value. 

  <div style="display: none;">
       {{ ticket_custom_keygoeshere }}
       {{ customer_custom_keygoeshere }}
       {{ company_custom_keygoeshere }}
    </div>

While the above happens inside of Desk, adding a string query to set a field happens outside of Desk, i.e. a user clicks on 'Submit Case' and you've edited the HTML link to include the string query.

When setting custom fields via query strings, you must first add the custom field to your form via the theme editor in Desk.com Admin

Next, we'll add ?<string_query>  to the end of the URL when linking to your support page. For example, if we add ?interaction[name]=John to the end of a URL to set the customer's name as John in Desk. Any standard or custom field is supported, except for address fields. You can even set multiple fields by adding additional strings to the URL.

URL that does not set any fields:
https://support.desk.com/customer/portal/emails/new

URL that sets the Customer's Name:
https://support.desk.com/customer/portal/emails/new?interaction[name]=Ty

Here is a list of string queries you can add to set fields on a case during case submission:

interaction[name]
interaction[email]
interaction[phone]
qna[subject], or q
qna[body]
 
customer[first_name]
customer[last_name]
customer[company]
customer[title]
customer[desc]
customer[custom_key]
 
ticket[subject] 
ticket[desc]
ticket[labels_new] - If the label does not exist, it will be created. 
ticket[priority]
ticket[custom_key]

company[custom_key]