6

How to: Hide specific fields from certain groups of agents

If you have multiple agents groups, and you don't want some agents to see some of the ticket fields, you can use the hack below.

In this example, the ticket_fields_21422908 will not be visible to agents who are not in administration group.

 

jQuery(function($) {

var USER_URL = $("a#top-right-name").attr("href");

var PARSED_XML = null;

var DOC_LOADED = false;

var XMLDATA = {};

function parseXml(xml) {

if (DOC_LOADED) {

processXML(xml);

} else {

PARSED_XML = xml;

}

}

function processXML(xml) {

var self = $(this);

var groupname;

var flag = false;

$(xml).find("group").each(function() {

groupname=$(this).find("name")[0].textContent;

if (groupname=="admins") {flag=true;};  //replace admins with your administration group

});

if (!flag) {

$("#ticket_fields_21422908").parent().remove(); //field to be removed 

}

}

function showError(XMLHttpRequest, textStatus, errorThrown) {

//alert(XMLHttpRequest + "--" + textStatus + "--" + errorThrown);

}

$.ajax({

type: "GET",

url: USER_URL,

dataType: "xml",

success: parseXml,

error: showError

});

if (PARSED_XML) {

processXML(PARSED_XML);

delete PARSED_XML;

} else {

DOC_LOADED = true;

}

})

28 comments

Please sign in to leave a comment.