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

My case isn't exactly what's being described here, but I think you all may be able to help me.

I need to hide a ticket form from the New Request page's source. The solutions shared here are excellent at hiding ticket forms from the New Request form dropdown via Javascript, but Javascript loads after the fact - which means all of those hidden forms are still plainly visible via the page source, even if they're not in the dropdown.

My company tests beta software so I need to hide those hidden forms from every possible vector (and a page's source is always just a click away), but I can't find a way to remove form links/IDs from the page source. I've determined this all comes back to the "{{request_form wysiwyg=true}}" helper, but any attempts to remove it or recreate the New Request page without it results in all ticket forms breaking entirely. 

Anybody know how I can plug this leaky helper?

0


Gavin・ギャビン, I understand your concern  but I took the reference from here:

https://developer.zendesk.com/api-reference/widget/settings/

 

and I haven't other idea instead of this so I shared this with you.

 

Yes, this code is added to script.js file.

0


Thanks Ifra Saqlain

Does this go into the script.js file?

What if we want to do the inverse?  We have about a dozen forms, and only want to hide one or two of them.  Is there a way to say "hide these forms" instead of "show these forms"?

0


Hi Gavin・ギャビン,

 

You can do like this, I have 6 forms but I want to show two forms in my web widget so I added the IDs only for two forms:

window.zESettings = {
  webWidget: {
    contactForm: {
      ticketForms: [
         { id: 360003074611},
         { id: 360001547211},
      ]
    }
  }
};



Output:


{ id: 360003074611},
{ id: 360001547211},

These both are my form's Ids which I wanna show.


 

 

0


Hello.

I successfully used these instructions to remove my form from the form-selection-list.

https://support.zendesk.com/hc/en-us/community/posts/4409217680410/comments/4409692632474

However the form still appears in the Web Widget as a selectable form.  How can I remove it from the Web Widget, also?

0


Hey Alyssa, here is a post for same query you are asking for:

https://support.zendesk.com/hc/en-us/community/posts/5050937568666-Prefill-and-hide-Subject-Description-fields-of-specific-form-on-New-Request-Template

There is JS instead of jQuery, please take a look at it.

If any query feel free to ask :)

Thanks

 

0


Hi folx!

I had previously used this solution, however, we've opted to use Zenplates which uses vanilla Javascript and not jQuery. Ifra Saqlain do you possibly have a solution for hiding ticket forms using vanilla Javascript? Appreciate any help our resources you can share! 

0


Finally you got it done!

1


Ifra Saqlain That's worked, thank you for all your time and patience on this. 

Hopefully now for anyone coming along that wants to use the forms on the home page and also in the nesty panel this code will help them.

I don't like the look of the nesty panel alone hence why I use the links to forms on homepage, its much cleaner. 

The fact that we can hide a from from Anonymous users and also Organisation Users is fantastic so well done for your work on this, this is going to be a big game changer for how I arrange my forms, and for anyone else looking to use this solution. 

Thanks to Pulkit Pandey also for your piece at the end. 

0


Try this:

// 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(); 

}  

1


Sign in to leave a comment.

Didn't find what you're looking for?

New post