Hiding a ticket form on the 'submit a request' page

Answered


Posted Aug 12, 2021

Hi!

I need to know how to hide a form from the 'submit a request' page drop down option, we don't want customers able to select it from the list (we are currently doing a trial by sending them a hyperlink to it through email contact). Customers are not required to sign in to submit a form so we can't use the option of hiding dependant on organisation (saw an article recommending this).

Does anyone know how I can do this please? Newbie coder here so not sure how to go around doing this!


2

100

100 comments

Hi Ifra Saqlain

No that didn't work for me, its not hiding homepage form or nesty form now. I'm conscious I've used a lot of your time now so thank you. 

0


Paul once try this, remove all code which have shared above and add the below code:

// Hide the forms from Anonymous Users    
    
$(document).ready(function () {
   for (var c in HelpCenter.user.organizations) {
         if(HelpCenter.user.organizations[c].name == "Students") {
if (HelpCenter.user.role=="anonymous") {
// Hide the graduation form from Homepage    
    
if (window.location.href.indexOf("?ticket_form_id") > -1) {
      console.log("yes!");
    } else {
      var _x = $(".list-group > a[href*='7446275690524']").remove();
    }
}


//Code for some specific ticket forms -- Start

var tagsToRemove = ['7446275690524'];  //special form ID

function removeTagsWeDontWant() {
$('.nesty-panel').on('DOMNodeInserted', function(e){
for(var i in tagsToRemove) {
$('li#' + tagsToRemove[i]).remove();
}
});
};

if (HelpCenter.user.role=="anonymous") {
removeTagsWeDontWant();
}
// End
     }
   }
});  

0


Hi Ifra Saqlain and Pulkit Pandey

I have used both your code and it appears I'm getting closer to getting this working, so thank you both. 

I had to create two sections of code, one above the other, all seems to be working, its hiding the forms from students and anonymous users on both the homepage and nesty. 

The only issue I'm facing now is the form is showing on the homepage for staff users which is correct as I have not hidden it from staff users, but its hiding the form in the nesty panel for staff users, which is not correct. 

This has something to do with Part 2 of the code, any ideas what this might be?

Part 1 - Hiding the Form on the homepage from Anonymous users/ Works perfect.

// Hide the forms from Anonymous Users    
    
$(document).ready(function () {

if (HelpCenter.user.role=="anonymous") {
// Hide the graduation form from Homepage    
    
if (window.location.href.indexOf("?ticket_form_id") > -1) {
      console.log("yes!");
    } else {
      var _x = $(".list-group > a[href*='7446275690524']").remove();
    }
}


//Code for some specific ticket forms -- Start

var tagsToRemove = ['7446275690524'];  //special form ID

function removeTagsWeDontWant() {
$('.nesty-panel').on('DOMNodeInserted', function(e){
for(var i in tagsToRemove) {
$('li#' + tagsToRemove[i]).remove();
}
});
};

if (HelpCenter.user.role=="anonymous") {
removeTagsWeDontWant();
}
// End

});  

Part 2 - Hiding the Form from users with the oganisation name = Students

// Hide the forms from users with Orgnaisation name "Students"        
    
function removeForm() {
       for (var c in HelpCenter.user.organizations) {
         if(HelpCenter.user.organizations[c].name == "Students") {
           $(".list-group a[href*='7446275690524']").hide();
         }
      
         else {
            $(".list-group a[href*='7446275690524']").show();
         }
     }
  };
  removeForm();    
    
    
 // Hide the graduation form from Nesty Panel    
   
     for (var c in HelpCenter.user.organizations) {
 if(HelpCenter.user.organizations[c].name == "Students") {
 } 
    
var tagsToRemove = ['7446275690524'];  //special form ID

function removeTagsWeDontWant() {
$('.nesty-panel').on('DOMNodeInserted', function(e){

for(var i in tagsToRemove) {
$('li#' + tagsToRemove[i]).remove();
}
});
};
removeTagsWeDontWant(); 
  
}   

Together

// Hide the forms from Anonymous Users    
    
$(document).ready(function () {

if (HelpCenter.user.role=="anonymous") {
// Hide the graduation form from Homepage    
    
if (window.location.href.indexOf("?ticket_form_id") > -1) {
      console.log("yes!");
    } else {
      var _x = $(".list-group > a[href*='7446275690524']").remove();
    }
}


//Code for some specific ticket forms -- Start

var tagsToRemove = ['7446275690524'];  //special form ID

function removeTagsWeDontWant() {
$('.nesty-panel').on('DOMNodeInserted', function(e){
for(var i in tagsToRemove) {
$('li#' + tagsToRemove[i]).remove();
}
});
};

if (HelpCenter.user.role=="anonymous") {
removeTagsWeDontWant();
}
// End

});     
    
// Hide the forms from users with Orgnaisation name "Students"        
    
function removeForm() {
       for (var c in HelpCenter.user.organizations) {
         if(HelpCenter.user.organizations[c].name == "Students") {
           $(".list-group a[href*='7446275690524']").hide();
         }
      
         else {
            $(".list-group a[href*='7446275690524']").show();
         }
     }
  };
  removeForm();    
    
 // Hide the graduation form from Nesty Panel    
   
     for (var c in HelpCenter.user.organizations) {
 if(HelpCenter.user.organizations[c].name == "Students") {
 } 
    
var tagsToRemove = ['7446275690524'];  //special form ID

function removeTagsWeDontWant() {
$('.nesty-panel').on('DOMNodeInserted', function(e){

for(var i in tagsToRemove) {
$('li#' + tagsToRemove[i]).remove();
}
});
};
removeTagsWeDontWant(); 

}   

0


Hi Paul H

Please, replace the previous code which I shared with the current one 

  function removeForm() {
       for (var c in HelpCenter.user.organizations) {
         if(HelpCenter.user.organizations[c].name === "Students") {
           $(".list-group a[href*='7446275690524']").hide();
         }
       else if(HelpCenter.user.role === 'anonymous') {
         $(".list-group a[href*='7446275690524']").hide();
       }
         
         else {
            $(".list-group a[href*='7446275690524']").show();
         }
     }
  };
  removeForm();

Let me know if it solves your issue

 

Thank you 

Pulkit

Team Diziana

0


Paul H

Copy the code and paste it and see homepage:

$(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 === "Students"){
 $("#7446275690524").remove();
 } 
 
 //reserve space for additional organizations 
 }
 
 });
 });
 }
 if (i > 10){
 clearInterval(checkExist);
 }

 }, 100);

// Hide form from Homepage   
  
if (window.location.href.indexOf("?ticket_form_id") > -1) {
 for (var c in HelpCenter.user.organizations) {
if (HelpCenter.user.organizations[c].name === "Students"){
      console.log("yes!");
    } else {
  var _x = $(".list-group > a[href*='7446275690524']").remove();
    }
}
}
});

 

You have anchor tag in code in your inspect element tab:

<a class="list-group-item list-group-item-action p-4" href="/hc/en-ie/requests/new?ticket_form_id=7446275690524">

            <div class="media align-items-center">

              <div class="media-body font-semibold">

               Digital Learning

              </div>

              <svg class="svg-icon fill-current text-primary ml-2" viewBox="0 0 190 323" xmlns="http://www.w3.org/2000/svg">

                <path d="M190,162 C190,168 187,174 183,178 L38,317 C34,321 28,323 23,323 C17,323 11,321 7,317 C-2,308 -2,294 7,285 L135,162 L7,39 C-2,31 -2,16 7,7 C15,-2 29,-2 38,7 L183,146 C187,150 190,156 190,162 Z"></path>

              </svg>

            </div>

          </a>

 

See the anchot tag and it has form ID:  7446275690524

<a class="list-group-item list-group-item-action p-4" href="/hc/en-ie/requests/new?ticket_form_id=7446275690524">

This form ID 7446275690524 is your Digital Learning form. So your Digital Learning form will hide on homepage if this form organisation is Students else it won't hide.

You can copy this id and add it to your script code and then test.

 

Another way is,

tell the form's name with it's organizations which you wanna hide on homepage, so I'll share the right code as per your requirements.

 

0


Hi Pulkit Pandey

Thanks for the code, it works on the nesty panel thanks you but not on the forms i have located on my requests page. 

The forms are just url in anchors that bring the user to the form nesty panel. 

0


Hi Ifra Saqlain,

Thanks for all your help, as I'm using SSO I'm not able to get you access to our Zendesk portal, but thank you for the offer. 

I don't see any from ID anchor tag in my console on homepage. If im looking in the wrong place maybe you could let me know. 

<a class="list-group-item list-group-item-action p-4" href="/hc/en-ie/requests/new?ticket_form_id=7446275690524">
            <div class="media align-items-center">
              <div class="media-body font-semibold">
               Digital Learning
              </div>
              <svg class="svg-icon fill-current text-primary ml-2" viewBox="0 0 190 323" xmlns="http://www.w3.org/2000/svg">
                <path d="M190,162 C190,168 187,174 183,178 L38,317 C34,321 28,323 23,323 C17,323 11,321 7,317 C-2,308 -2,294 7,285 L135,162 L7,39 C-2,31 -2,16 7,7 C15,-2 29,-2 38,7 L183,146 C187,150 190,156 190,162 Z"></path>
              </svg>
            </div>
          </a>

0


Hi Paul H

Please, Add the below code at the bottom of your script.js file

  
var formToRemove = ['5550538483484'];
function removeForm() {
  $('.nesty-panel').on('DOMNodeInserted', function(e){
      for(var i in formToRemove) {
        for (var c in HelpCenter.user.organizations) {
            if(HelpCenter.user.organizations[c].name === "student"){
            $('li#' + formToRemove[i]).hide();
            } 
        }
        }
       });
  };
 removeForm();

Let me know if it solves your issue

 

Thank You 

Pulkit

Team Diziana

0


Just go to the homepage of your forms and right click > inspect > select on any form > you will get the anchor tag.

Tell your all form name which you want to hide, I'll share the code then you need to add as it is.

Finally I'm thinking that send your HC credential on my personal mail id and tell exact query then I'll do that by myself at night after that you can change the password.

0


Hi Ifra Saqlain

I was never able to find the anchor tags, still stuck on the piece of hiding the forms from the homepage. Have you any other ideas of how I could achieve this?

Kindest,

Paul

0


Sign in to leave a comment.

Didn't find what you're looking for?

New post