Last active
November 20, 2018 14:36
-
-
Save mgdiez/030d8c7c491382b2a54e3f6dd4151ed2 to your computer and use it in GitHub Desktop.
Zendesk populate fields
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var field_data = { | |
"anonymous_requester_email": "", // email | |
"subject": "", // subject | |
"description": "that shit cray", // description | |
"custom_fields_XXXXXXX": "", // your custom field | |
} | |
// parse it out for our url format | |
var q = [] | |
for ( var k in field_data ) { | |
if (field_data.hasOwnProperty(k)) { | |
q.push('request_fields[' + k + ']=' + encodeURIComponent(field_data[k]) ) | |
} | |
} | |
// wrap it up | |
var zd_url = 'url here' | |
var redirect_url = zd_url + q.join('&') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(function($) { | |
if ( !$('#new_request') ) return | |
var query = window.location.search.substring(1); | |
var vars = query.split("&"); | |
var match, fieldID; | |
for (var i=0; i<vars.length; i++) { | |
var pair = vars[i].split("="); | |
match = pair[0].match(/^request_fields\[([a-z_\d]+)\]$/) | |
if (match) { | |
fieldID = match[1]; | |
$('#request_' + fieldID).val( decodeURIComponent(pair[1]) ); | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(function($) { | |
if ( !$('#new_request') ) return | |
var query = window.location.search.substring(1); | |
var vars = query.split("&"); | |
for (var i=0; i<vars.length; i++) { | |
var pair = vars[i].split("="); | |
$('#request_'+ pair[0]).val(decodeURIComponent(pair[1])); | |
} | |
$('.form-field.string.optional.request_custom_fields_360000382359').hide() | |
$('.form-field.string.optional.request_custom_fields_360000357665').hide() | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment