Zendesk: hide ticket fields based on a user’s organisation

Zendesk: hide ticket fields based on a user’s organisation

⚠️ You are reading a post that has been archived. This means the content:
  • could be very old (up to 15 years!)
  • could not be accurate anymore
  • could not represent the views of the author anymore
  • could be in le French

It’s cool to display ticket fields to agents and/or end users, but what if you have different organisations in the same Zendesk and want to hide specific fields only for people in a specific organisation? Well, say no more! 🙂

The requirement
In one of my Zendesk environment I have 3 organisations: organisation of customer 1, organisation of customer 2 and our internal organisation (our company). Whenever end users, agents or light agents from our company are checking a ticket, I want them to see a specific ticket field that contains an internal reference. If people from organisation of customer 1 or 2 are checking out the same ticket I don’t want them to see that internal reference.
The solution
Create a Global JavaScript extension in which you replace var organization_ids = [20863746] by the actual ID of the organisation that shouldn’t see the field (you can have the ID via Manage> People> Organisations) and replace id_to_remove = “#ticket_fields_20813026” by the unique ID of your custom field. Or even, by modifying the code a bit, simply put there the CSS ID of the field.

//START hide field based on organisation
jQuery(function($) {
	var organization_ids = [22071016],
//Insert here the ID from the organisation which shouldn't see the field
		id_to_remove = "#ticket_fields_20813026",
//Insert here the ID of custom field or the DIV ID of a system field you want to hide
		user_url = jQuery("a#top-right-name").attr("href");
jQuery.getJSON(user_url, {}, function(data){
	 if (organization_ids.indexOf(data.organization_id) >= 0){
//END hide field based on organisation
The result
This is the internal view
This is the customer's view. Hey, something disappeared!
The source
Available on my GitHub account

Leave a Reply