Created
May 2, 2013 20:25
-
-
Save skipjac/5505114 to your computer and use it in GitHub Desktop.
This is a Zendesk Classic widget that will hide ticket fields and then only show them with the agent is part of a allowed group list
This file contains 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(document).ready(function() { | |
//list of fields to hide | |
var options = ['#ticket_fields_139051']; | |
//groups allowed to see the fields | |
var allowGroups = [88054]; | |
//function to hide a array of arrays | |
var hide = function(){ | |
$j.each(arguments, function(i, item){ | |
for(y = 0; y < item.length; y++){ | |
$j(item[y]).parent().hide(); | |
} | |
} | |
); | |
} | |
//function to show a array of arrays | |
var show = function(){ | |
$j.each(arguments, function(i, item){ | |
for(y = 0; y < item.length; y++){ | |
$j(item[y]).parent().show(); | |
} | |
} | |
); | |
} | |
//hide the fields | |
hide(options) | |
//get the current users groups and show the fields if the user is in the allowed groups | |
$j.getJSON('/' + currentUser.version, function(data){ | |
_.each(data.groups, function(x){ | |
var inArr = _.contains(allowGroups, x.id); | |
if(inArr) { | |
show(options); | |
} | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment