Question
How can I hide ticket forms based on a user's organization?
Answer
Disclaimer: This article is provided for instructional purposes only. Zendesk does not support or guarantee the code. Zendesk also can't provide support for third-party technologies such as JavaScript, jQuery, or CSS. Please post any issues you have in the comments section or try searching for a solution online.
To hide specific ticket forms based on the user's organization name, perform the following steps:
Note: If your theme uses Guide Templating V2, jQuery will need to be imported. For full details, see the article: Importing or upgrading jQuery.
Step 1: Find the ticket form ID
- Go to Admin Center, navigate to the Ticket Forms page, then select the appropriate ticket form.
- Find the ID number in the URL after the last slash.
Step 2: Find the organization name
- Go to Admin Center, navigate to the People page.
- Browse or search for organizations to find the right organization name.
Step 3: Edit the JavaScript
- In Guide, click the Customize design icon (
) in the sidebar. The Theme page opens.
- Click the theme you want to edit to open it.
- Click the options menu and select Edit Code and select script.js.
- Copy the code block below.
$(window).on('load', function() {
var i = 0;
var checkExist = setInterval(function() {
i++;
if ($("a.nesty-input").length){
clearInterval(checkExist);
$("a.nesty-input").each(function() {
$(this).bind( "click", function() {
for (var c in HelpCenter.user.organizations) {
if (HelpCenter.user.organizations[c].name !== "ZENDESK"){
$("#TICKET_FORM_ID").remove();
}
//reserve space for additional organizations
}
});
});
}
if (i > 10){
clearInterval(checkExist);
}
}, 100);
}); - Replace "TICKET_FORM_ID" with the actual ticket form ID.
- Replace "ZENDESK" with the actual organization you want the ticket form to show for.
- Paste the code into the JavaScript template of your Help Center code.
- Save your template and publish changes.
The provided code reserves space for additional organizations. To add additional forms and organizations, copy the if statement above and place it under the existing if statement like below ensuring to replace the ticket form id with the correct one and the organization you want to check and see if the user is in. Repeat this for however many ticket forms and organizations you want.
for (var c in HelpCenter.user.organizations) {
if (HelpCenter.user.organizations[c].name !== "ZENDESK"){
$("#TICKT_FORM_ID").remove();
}if (HelpCenter.user.organizations[c].name !== "MYORG"){
$("#TICKET_FORM_ID2").remove();
}
Note: This workflow doesn't work for unauthenticated users or users who don't have an organization. For these users, all the forms will display.
65 Comments
Hi all,
It would be great to have this as native function. Being able to hide or show a form based on organisation would great to have without going to the code. Is there any plans for this?
Has anyone been able to get this to work? I have tried a few solutions from the comments but not having any luck.
Our goal is to HIDE a single form from ALL users, except those with a specific tag. Speaking of tags, is the tag based on user tag? Org tag? User segment name?
What's the best way to accomplish this?
Hi @...
Based on what has been posted before, you want to add the following code to your template:
In style.css:
In script.js:
It's untested but it should work.
Hi,
Does anyone have updated this in VanillaJs instead of Jquery ?
My code worked fine in V1 with Jquery but not in V2 (with JQUERY in document_head).
thanks a lot
Hi all.
I recently implemented this solution but it's populated a drop down list across the board despite both organisations only having one form.
Does anyone know what edits to make to ensure there is no drop down and instead, users are automatically redirected to the only form that is visible?
Hi Gabriel Manlapig, thank you for your help but I would like to hide the dropdown menu in general and not after selecting a form.
So, lets say that there are 3 forms A, B and C. And 3 different companies company1, company2 and company3.
The forms are customized in a way that form A is only shown to company1, form B is only shown to company B and form C is shown to company3. The problem is that when you click on submit, there is still a dropdown menu, when you want different companies to land on their own forms directly and not get a dropdown menu despite having one form to show.
I have managed to "translate" the first part, but I'm still stuck with the $(this).children('ul').children().remove('#TICKET_FORM_ID') JQuery which looks too "complex" to be easily translated. So the code looks like this now:
It works, but it is very ugly since it mixes Vanilla JS and JQuery.
Help on making it 100% Vanilla JS would be very appreciated.
Hi Adam,
Yes it's possible to use organization tags instead of name.
The following command displays the whole HelpCenter object in the console:
In this object, "user.organizations" is an array. For each organization, you have access to the "name" and "tags" properties.
As to your second question, this code only works in V1 because you need the JQuery dependency, which is not available in V2. Should you want this code to work in V2, you'd either have to adapt it or inject the JQuery dependence.
Hi Julien 👋
Almost there.. this should be the final part to remove jQuery completely
I know of an easy way to hide specific ticket forms from anyone. I use this method because I want some forms to be only available from specific web widgets, while not using brands:
However, this uses JQuery. I would like to convert to VanillaJS but I have failed so far. Does anyone know how to translate this into VanillaJS?
Hi Kay,
Wow, you just saved my day (and nights)! This works exactly the way I intend to! Thanks a lot :-)
For the record, here is a "template" snippet if anyone wishes to do the same:
Thanks again to Kay for the help!
Regards
Are there plans to introduce native access controls to ticket forms? Using jQuery is fine on the surface (we use it currently!) but it's really just security through obscurity. Anyone can access the developer console in their browser, find the form ID, and then plug it into the URL. The same would be true with hiding and replacing the form picker, as the form selector is built into the {{request_form}} helper.
This is especially problematic for those who might have "unadvertised processes" in their org that necessitate ticket forms - how do you keep them from finding out, except build the form outside Zendesk?
HI @...
Thanks! I will give it a try. Since we are using the Single Sign On as well I will also consult with our Dev Team.
I will get back on it once we have it up and running so other members of the community can benefit as well.
Regards,
Ron
Hi,
I am looking to hide certain custom ticket field dropdown options and some ticket fields based on the form selected, how could I do that?
Hi I'm trying to hide forms from all people outside of an organization. Can someone help??
:(
My current version is:
For each section (in BOLD) I put the following:
SCRIPT.JS section
//Hide Form
var i = 0;
var checkExist = setInterval(function() {
i++;
if ($("a.nesty-input").length){
clearInterval(checkExist);
$("a.nesty-input").each(function() {
$(this).bind( "click", function() {
for (var c in HelpCenter.user.organizations) {
if (HelpCenter.user.organizations[c].name ==="Main Company"){
$("#7286425102107").show();
}
else {
$("#7286425102107").hide();
}
//reserve space for additional organizations
}
});
});
}
if (i > 10){
clearInterval(checkExist);
}
}, 100);
DOCUMENT_HEAD.HBS Section
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
STYLE.CSS section
@keyframs animSlideTop {
0% { -webkit-transform:translate3d(0,-100%,0); transform: translate3d(0,-100%,0); }
100% { -webkit-transform:translate3d(0,0,0); transform: translate3d(0,0,0); }
#7286425102107{
display: none;
Is @keyframes supposed to be in the Style.css? I tried it both ways, with and without. Either way the form still shows for people outside of the organization "Main Company".
Great article, although it doesn't show how to hide the same forms from the web widget. Also, I don't get why it provides a jQuery snippet since it's not natively supported in HelpCenter V2.
The feedback given by other users to this article, helped me figure out how to hide based on user tags, here is a working template in Vanilla JS, which is supported in HelpCenter V1 and V2 (you just need to replace the "TICKET_FORM_ID" and the user tags you need to target). And it takes care of the web widget as well.
In my use case, I needed to grant access to specific forms only to users from specific departments ("people" and "franchising_operations"). I left the tags in there to make it more simple to understand.
Feel free to suggest improvements to my code.
Hi John,
May it be that you moved to templating API v2 on which jquery is no longer available?
I'm still using API v1 and it all works fine.
Hi,
Is it possible to write something so that the Default form is the only form in the Help Center available to users?
We have many forms that are specific to projects that are only seen to our users in the web widget, but when in the help center creating a follow up they can click to any of our project form types. We'd like all follow-ups to come in on the Default form and then the team can triage.
Thanks!
Amanda
Morning @...!
Thank you very much for your follow-up! Nevertheless, none of your suggestions is working here :
var remove_360001704540 = true;
var remove_360001714479 = true;
for (var c in HelpCenter.user.organizations) {
if (["X", "Y", "Z"].includesconsole.log(HelpCenter.user.organizations[c].name)){
remove_360001704540 = false;
}
if console.log(HelpCenter.user.organizations[c].name == "A"){
remove_360001714479 = false;
}
}
if console.log(remove_360001704540) {
$("#360001704540").remove();
}
if console.log(remove_360001714479) {
$("#360001714479").remove();
}
When I add the console.log, I loose my possibility to log out again...
I thought it was easy to do but in fact no haha!
Is it possible to hide it for users who are not signed in as well?
Hello @...!
Thank you so much for your quick answer!
I have thus replaced my previous code by this one as you suggested but it still doesn't work (I have the log out back, this is already one good thing though!), I still have both forms for both users linked to those organizations... :
var remove_form1 = true;
var remove_form2 = true;
for (var c in HelpCenter.user.organizations) {
if (["X", "Y", "Z"].includes(HelpCenter.user.organizations[c].name)){
remove_form1 = false;
}
if (HelpCenter.user.organizations[c].name == "A"){
remove_form2 = false;
}
}
if (remove_form1) {
$(360001704540).remove();
}
if (remove_form2) {
$(360001714479).remove();
}
Still don't understand why :-(
John DiGregorio if you want to use this script in V2 API you have to :
- insert link to jquery in your document_head
- remove first line $(window).on('load......
-> Look at my answer on the other post https://support.zendesk.com/hc/fr/community/posts/4572609525786-Hiding-a-Form-From-All-Users-Except-Member-of-an-Organization?page=2#comments
Hi Andrea Rochira
Thank you for your updated code snippet, this has worked perfectly for our needs in testing so far.
I have a follow-up question you might be able to help me answer.
Q: Have you been able to hide the form from anonymous end-users?
We currently allow any end-user to submit a ticket request to us, and forcing a user to login using the helper {{#if signed_in}} is preventing our anonymous end-users from submitting a ticket.
Any thoughts you might have would be great.
Hi @...
Thanks for jumping in. The .css works just fine however the JS code doesn't render as expected. I did assign the tag (comments_visible) to the organisation within ZenDesk. Maybe you're able to assist with the code for checking on the organisation name as well?
Am I right that the code should be under the $(document).ready(function() { function?
Just to be complete, this is the code I tried and didn't work out:
And this is the organisation with the tag:

Has anyone gotten a version of the above working against Templating API v2 ?
if you want to hide your form for Davetopia's users, try to modify this
by this :
if (Helpcenter.user.organizations[c].name === "Davetopia")
Thanks for clarifying that for me, Noelle Cheng!
I'm going to pull this in to a ticket so we can look at your code in a bit more detail. You should see an email coming through from me shortly.
Thanks!
Tipene
Hi Morteza,
I found this community post that provides insight on how to hide a ticket form selector.
https://support.zendesk.com/hc/en-us/community/posts/4409515399066-How-to-disable-the-ticket-form-dropdown
Please note that the suggestions mentioned in the community post was not created by Zendesk. If you have any questions or issues, please reach out to the post above for further assistance. Thank you!
Thanks - I will give this a try
Thank you for reaching out to Zendesk Support.
In regards to your question, I don't see any other way to do the following method. Also worth noting is that the following method mentioned here is for instructinal purposes only and Zendesk doesn't support or guarantee the code.
Thank you!
Kind regards,
Please sign in to leave a comment.