Hide ticket forms based on user's organization (Professional add-on and Enterprise)

Have more questions? Submit a request

48 Comments

  • Drew Hayes
    Comment actions Permalink

    @Ryan, 

    Thanks for sharing! As I am not an experienced coder by any means, would you please point out which portions of your code need to be replaced (forms, tags, etc.) within your example before I try to implement it and get something wrong? I tried in testing a bit, but apparently did something incorrect. 

    0
  • Ryan M Mayes
    Comment actions Permalink

    Hi Drew,

    Using the code as-is, add a prefix to each ticket form name that matches a tag on the users that you want to see that ticket form.

    For example:

    User John has tag "learner". If you rename a ticket form to "learner - repair form", John will be able to see the form, but other users who do not have the "learner" tag will not be able to see the form.

    -Ryan

    1
  • Drew Hayes
    Comment actions Permalink

    Ahh - Thanks, Ryan. That makes sense. Too easy - I was trying to over complicate it! :) 

    0
  • Jessie Schutz
    Comment actions Permalink

    Hey Ryan! 

    Thank you so much for coming back to answer questions about your comment! If you'd like, feel free to write it up for our Tips & Tricks topic. You'll get swag in addition to fame. :)

    0
  • Dan Derks
    Comment actions Permalink

    Hi Ryan!

    In the midst of expanding my org's use of ZenDesk to include internal support. I want to create a form that only folks who are tagged with 'isr' (Internal Support Requester) can see. I copied your original code into my script.js file and have renamed a form 'ISR - request', but the form remains publicly available.

    Any guidance (though you've provided more than enough over the years!) would be appreciated :)

    Best,

    Dan

    0
  • Mike West
    Comment actions Permalink

    What's the best method for hiding a specific form always, regardless of the user's organization or any other criteria?

    I have a form that I'd like to link to from a very specific Help Center article only. I don't want a user to ever be able to select this form from the drop-down list.

    Thanks in advance.

     

    0
  • Jessie Schutz
    Comment actions Permalink

    Hi Mike!

    I imagine that you can use code similar to this to hide the form from all users, rather than just certain users. All this does is remove it from the dropdown so users can't select it - the form still exists, and you should be able to link directly to it. I can't help with code specifics but we have plenty of helpful tips provided by community members that can help get you started!

    0
  • Uriel Flores
    Comment actions Permalink

    Hello,

     

    We currently have 1 default form, which all organizations use. We included an additional form for 8 organizations that have an additional service, aside from their current. We used the script above and successfully works. However, is there a method that we can use for all organizations that do not have the additional service that we offer, be directed straight to our default form, instead of having to select the default form from the drop-down menu? Currently, organizations that do not have our additional service, have to click the default form to submit a regular ticket, which is an additional step for them (other form is hidden). Is there a way to show our 8 organizations the two different forms only, and not have the other organizations have to select the only form that they need to submit a ticket and just be directed to the default ticket form?

     

    Thanks.

    0
  • Fernando Duarte
    Comment actions Permalink

    I would give those users a direct link to the specific form rather to the forms page

    0
  • Anders Vännman
    Comment actions Permalink

    Pew. This was advanced for a much needed feature. Would be so much nicer if one it was possible to do this right from the admin interface, where i create the ticket forms, a field "show only for  these organisations" and "show only for users with these tags", or something similar.

     

    4
  • Xavi
    Comment actions Permalink

    @Ryan, thanks for sharing your code.

    Does it mean that all users shall have a tag corresponding to the prefix of every form they need to access ?

    For example :

    I have a form called "General" and i want all my users to be able to access this form. So, with your code, all my users shall have a tag "General"?

    The problem would be forgetting to add this tag when we add 1 new user.

    Thanks in advance

    0
  • Steve Morrell
    Comment actions Permalink

    We have implemented this, and it is mostly working well. However, it seems that remove() is not supported on IE11, so users are seeing multiple forms for this.

    https://stackoverflow.com/questions/20428877/javascript-remove-doesnt-work-in-ie

    So far the suggestions in the above article haven't worked. Does anyone have any other thoughts?

    0
  • Wesley Bowles
    Comment actions Permalink

    Can anyone help me with the JS i would need for the following? I've read through most of the previous comments and most of the modifications don't seem to quite match up with what i need. 

    We only have two forms. Our default and "form2". Basically we only want users with a specific user tag to see "form2" in addition to our default form. everyone else without this tag would only see the default form. 

    Thank you in advance for any assistance. 

    0
  • Kay
    Comment actions Permalink

    Hi Wesley,

    This should point you in the right direction.

    ⚠️This snippet of code is quickly written, have your developer check against this.

    // only on the new request page and only if the user does not have a certain tag
    if(window.location.href.indexOf("/requests/new") > -1
    && !HelpCenter.user.tags.includes('VIP')) {

    // the form ID that needs to be hidden
    var formID = "74185";

    // remove from DOM, the select option and the UI by Zendesk
    document.querySelector('.request_ticket_form_id > a.nesty-input').addEventListener('click', removeItem);
    document.querySelector('#request_issue_type_select option[value~="'+formID+'"]').remove();

    // remove the element from DOM
    function removeItem(){
    var el = document.getElementById(formID);
    if(el) el.remove();
    }
    }

     

    0
  • Justin
    Comment actions Permalink

    Can we hide a ticket form from the drop down for ALL users regardless of org? The form would only be accessibly via a direct link...

    0
  • Wesley Bowles
    Comment actions Permalink

    Kay Thank you, that worked like a charm with some slight modification. 

    0
  • Alex Gillum-Webb
    Comment actions Permalink

    Hi folks,

    Looking for some advice on hiding a button on our home page (essentially submit a request) unless it is a specific Organization (either by ID, name or Tags).

    So far I have given the button an ID 'tamper' on the home page:

    <form style="display: block; text-align: center; margin: 20px;" class="submitbutton"
    action="{{page_path 'new_request'}}">
    <input type="submit" id="tamper" value="Tamper Label Upload">
    </form>

    Next I have set the button to be hidden by default in style.css:
    #tamper {
    display: none;
    }

     So far so good. I'm having trouble getting a function into the javascript to work. So far I have tried Robberts code with alteration (in bold):

     

    $(window).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 == "Test Org"){
    $("#tamper").show();
    }

    //reserve space for additional organizations
    }

    });
    });
    }
    if (i > 10){
    clearInterval(checkExist);
    }
    }, 100);
    });

    But I can't seem to get it to work. Where abouts in the the JS would this function need to sit?

    0
  • Brett - Community Manager
    Comment actions Permalink

    Hey Alex,

    I'm rather limited on what I can assist with on my end but I was able to track down the following tip that may help point you in the right direction:

    Hide/show community based on organization tags

    Hopefully, other users can jump in and offer up some guidance as well :)

    Cheers!

    0

Please sign in to leave a comment.

Powered by Zendesk