4 Comments

  • Maggie Ungerboeck
    Comment actions Permalink

    Hi Jason,

    We filter forms based on user segment. I didn't write this code but this is what I found in our script.js page for hiding/showing the ticket forms. Note that hosted_location is the user segment tag and I removed the form ID and replaced it with FORM_ID for this post. Hopefully this may provide you some assistance.

    for (var c in HelpCenter.user.organizations)
    {
    if (HelpCenter.user.organizations[c].tags.indexOf('hosted_location') > -1)
    {
    Hosted = "Yes";
    }
    }

    if (Hosted == "Yes")
    {
    console.log('The user should see the Hosted Patch Request form.');
    }
    else
    {
    $('#request_issue_type_selectoption[value="FORM_ID"]').remove();
    $('.nesty-panel').on('DOMNodeInserted', function(e)
    {
    $(this).children('ul').children().remove('#FORM_ID');
    console.log('The user should not see the Hosted Patch Request form.');
    });
    }

    Thanks.

    Maggie

    0
  • GCCTech
    Comment actions Permalink

    Hi, 

     

    I'm trying to do the same thing; I only want it to show a certain form to users who have tag "supportagent". I used the below code but am still seeing the form for all users:

     

    for (var c in HelpCenter.user.organizations)
    {
    if (HelpCenter.user.organizations[c].tags.indexOf('supportagent') > -1)
    {
    supportagent = "Yes";
    }
    }

    if (supportagent == "Yes")
    {
    console.log('The user should see the PB Research Form.');
    }
    else
    {
    $('#request_issue_type_selectoption[value="360002126953"]').remove();
    $('.nesty-panel').on('DOMNodeInserted', function(e)
    {
    $(this).children('ul').children().remove('#360002126953');
    console.log('The user should not see the PB Research.');
    });
    }

     

     

     

    Any recommendations?

    0
  • Jason
    Comment actions Permalink

    Thanks Maggie - browser console throws a "Use of Mutation Events is deprecated. Use MutationObserver instead." error that seems to be driven by 'DOMNodeInserted'.  Do you see this behavior as well?

    0
  • Jason McCann
    Comment actions Permalink

    Thanks all - here's what I used

     

    /* ============================================================*/
    /***** Hide ticket forms based on tags *****/
    /** reference: https://support.zendesk.com/hc/en-us/articles/204579603-Hide-ticket-forms-based-on-user-s-organization-Professional-add-on-and-Enterprise- */
    /* ============================================================*/

    $(window).load(function () {
    var i = 0;
    var group1 = HelpCenter.user.tags.includes('group1');
    var group2 = HelpCenter.user.tags.includes('fieldmember');
    var group3 = HelpCenter.user.tags.includes('group3ustrial');

    var checkExist = setInterval(function () {
    i++;
    if ($("a.nesty-input").length) {
    clearInterval(checkExist);
    $("a.nesty-input").each(function () {
    $(this).bind("click", function () {
    // display forms for group1
    if (group1 && !group2 && !group3) {
    $("#FORM_ID").remove(); // remove group3 form
    $("#FORM_ID").remove(); // remove default form
    $("#FORM_ID").remove(); // remove group2 form
    }
    // display forms for group2
    if (group2 && !group1) {
    $("#FORM_ID").remove(); // remove group3 form
    $("#FORM_ID").remove(); // remove default form
    $("#FORM_ID").remove(); // remove group1 form
    }
    // display forms for members of group1 and group2
    if (group1 && group2) {
    $("#FORM_ID").remove(); // remove group3 form
    $("#FORM_ID").remove(); // remove default form
    }
    // display forms for group3
    if (group1 && group3) {
    $("#FORM_ID").remove(); // remove default form
    $("#FORM_ID").remove(); // remove group2 form
    }
    });
    });
    }
    if (i > 10) {
    clearInterval(checkExist);
    }
    }, 100);
    });
    /* ============================================================*/

    0

Please sign in to leave a comment.

Powered by Zendesk