Skip to content

Instantly share code, notes, and snippets.

@akatz
Forked from jamesarosen/prefill.js
Created February 2, 2012 19:17
Show Gist options
  • Save akatz/1725201 to your computer and use it in GitHub Desktop.
Save akatz/1725201 to your computer and use it in GitHub Desktop.
Pre-fill custom fields in Zendesk
jQuery(function($) {
var customFieldParam = /^ticket\[fields\]\[(\d+)\]$/,
urlParams = $.queryParameters(),
k, match, fieldID;
// for each URL parameter:
for (k in urlParams) {
if (urlParams.hasOwnProperty(k)) {
// check whether it's a Zendesk custom field
match = k.match(customFieldParam);
if (match) {
// pull out the ID:
fieldID = match[1];
// and set the value in the UI:
$('#ticket_fields_' + fieldID).val(urlParams[k]);
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment