Skip to content

Instantly share code, notes, and snippets.

@jamesarosen
Created September 12, 2011 18:00
Show Gist options
  • Save jamesarosen/1211936 to your computer and use it in GitHub Desktop.
Save jamesarosen/1211936 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