{"id":38,"date":"2012-11-10T23:44:50","date_gmt":"2012-11-10T22:44:50","guid":{"rendered":"http:\/\/tempdetheux.food.blog\/2012\/11\/10\/zendesk-hide-ticket-fields-based-on-a-users-organisation\/"},"modified":"2019-07-19T17:02:05","modified_gmt":"2019-07-19T15:02:05","slug":"zendesk-hide-ticket-fields-based-on-a-users-organisation","status":"publish","type":"post","link":"https:\/\/arnaud.detheux.org\/blog\/zendesk-hide-ticket-fields-based-on-a-users-organisation\/","title":{"rendered":"Zendesk: hide ticket fields based on a user\u2019s organisation"},"content":{"rendered":"<div id=\"bsf_rt_marker\"><\/div><p>It\u2019s 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!&nbsp;\ud83d\ude42<\/p>\n<p>The requirement<br \/>\nIn 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\u2019t want them to see that internal reference.<br \/>\nThe solution<br \/>\nCreate a Global JavaScript extension in which you replace var organization_ids = [<em>20863746<\/em>] by the actual ID of the organisation that shouldn\u2019t see the field (you can have the ID via Manage&gt; People&gt; Organisations) and replace id_to_remove = \u201c#ticket_fields_<em>20813026<\/em>\u201d 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.<\/p>\n<pre>\/\/START hide field based on organisation\njQuery(function($) {\n\tvar organization_ids = [22071016],\n\/\/Insert here the ID from the organisation which shouldn't see the field\n\t\tid_to_remove = \"#ticket_fields_20813026\",\n\/\/Insert here the ID of custom field or the DIV ID of a system field you want to hide\n\t\tuser_url = jQuery(\"a#top-right-name\").attr(\"href\");<\/pre>\n<pre>jQuery.getJSON(user_url, {}, function(data){\n\t if (organization_ids.indexOf(data.organization_id) &gt;= 0){\n\t \tjQuery(id_to_remove).parent().remove()\n\t }\n\t})\n})\n\/\/END hide field based on organisation<\/pre>\n<pre>The result\nThis is the internal view<\/pre>\n<figure><img decoding=\"async\" data-width=\"1807\" data-height=\"489\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/0*sBqonNPj31Gc5QV1.png\"><\/figure>\n<pre>This is the customer's view. Hey, something disappeared!<\/pre>\n<figure><img decoding=\"async\" data-width=\"1807\" data-height=\"489\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/0*eRUyxNkHDpB6rDEX.png\"><\/figure>\n<pre>The source\nAvailable on <a href=\"https:\/\/github.com\/AdeTheux\/Zendesk-widgets\/blob\/master\/zendesk_hide_ticket_field_based_on_org.js\" target=\"_blank\" rel=\"noopener noreferrer\">my GitHub account<\/a><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>It\u2019s 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!&nbsp;\ud83d\ude42 The requirement In one of my Zendesk environment I have 3 organisations: organisation of customer 1,&hellip;<\/p>\n<p class=\"read-more\"><a class=\"readmore-btn\" href=\"https:\/\/arnaud.detheux.org\/blog\/zendesk-hide-ticket-fields-based-on-a-users-organisation\/\">Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","jetpack_post_was_ever_published":false},"categories":[7],"tags":[63,20,27,30,39,57],"class_list":["post-38","post","type-post","status-publish","format-standard","hentry","category-customer-experience","tag-archive","tag-customer-support","tag-field","tag-hack","tag-jquery","tag-zendesk"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/arnaud.detheux.org\/blog\/wp-json\/wp\/v2\/posts\/38","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/arnaud.detheux.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/arnaud.detheux.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/arnaud.detheux.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/arnaud.detheux.org\/blog\/wp-json\/wp\/v2\/comments?post=38"}],"version-history":[{"count":2,"href":"https:\/\/arnaud.detheux.org\/blog\/wp-json\/wp\/v2\/posts\/38\/revisions"}],"predecessor-version":[{"id":448,"href":"https:\/\/arnaud.detheux.org\/blog\/wp-json\/wp\/v2\/posts\/38\/revisions\/448"}],"wp:attachment":[{"href":"https:\/\/arnaud.detheux.org\/blog\/wp-json\/wp\/v2\/media?parent=38"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/arnaud.detheux.org\/blog\/wp-json\/wp\/v2\/categories?post=38"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/arnaud.detheux.org\/blog\/wp-json\/wp\/v2\/tags?post=38"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}