Hide ticket fields in web widget
AnsweredHi,
I would like to hide the email field in the web widget. I found this post: https://support.zendesk.com/hc/en-us/community/posts/360029388034-Hide-some-fields-from-the-widget-
It redirects you to this post: https://support.zendesk.com/hc/en-us/community/posts/360004395348-Hiding-system-fields-in-Web-Widget
Which I am not authorised to view. Can someone either help me with the js code, or give my access to view that post?
Thank you,
Amy
**Added 9th June: Feature Request (https://support.zendesk.com/hc/en-us/community/posts/360046753854-Feature-Request-Hide-ticket-fields-in-web-widget)**
-
Hello @...,
The link you shared lead to an old EAP that is no longer live, sorry for the confusion. I've gone ahead and updated that post, so it shouldn't cause any more trouble. As for your question, I'll see if our Moderator team can offer a solution. Otherwise, I'll be sure to share this in our Weekly Digest so other members of the community can share their expertise.
Best regards.
-
Thanks @... - I look forward to see if anyone can help me out here :)
-
@...
Try this code and see if it helps.
-
@... - Thanks. Unfortunately I can't get it to work.
I am putting in the script.js file and changed the below line to reflect the classes in my helpdesk
#Embed > div > div > div > form > div > div.sc-cpmKsF.fvnioU > div:nth-child(1) {
But it isn't hiding the fields. I don't think it's finding the fields to start with.
Any guidance? Thanks in advance
-
@...
Make sure you are putting the code after the initialization of the widget.
Note: This code is only run when the widget is opened.
By default, I commented out all of the individual lines to make sure that the code does not have unintended effects.
Make sure you uncommented the section you are trying to use.
The code should be added to the same place you are adding the initialization of the widget. You should not be inputting the file anywhere.
I updated the documentation at the link to help explain this.
-
@...
Yes, I missed that I had to put it after the widget. Thanks!
The bit that was breaking it for me is that in your code you have forgotten to close the function. Just in case any one else needs this code :)
Thank you so much on helping me fix days of torment! Much appreciated. -
@...
I will update that right away.
Glad the code helped you.
I was tired of seeing the same requests for the past 5 years and Zendesk not doing anything about it.
-
Active Feature Request (please vote):
Feature Request: Hide ticket fields in web widget
@...
I just posted a Feature Request for this at the link below. If you would like to see this feature please head over there and show your support. Please make sure to add an upvote and comment even if it is simply a "+1"
Also, you may consider adding it to your post to get the feature request more visible.
-
We solved this using this Javascript, where "xszt60-1.dLJShQ" is different for each widget.
<script type="text/javascript">
zE('webWidget:on', 'open', function () {
var style = document.createElement('style');
/*name*/
style.innerHTML = `.xszt60-1.dLJShQ > div:nth-child(1) {display: none;}`;
/*email*/
style.innerHTML += `.xszt60-1.dLJShQ > div:nth-child(2) {display: none;}`;
/*organization*/
style.innerHTML += `.xszt60-1.dLJShQ > div:nth-child(3) {display: none;}`;
parent.document.getElementById('webWidget').contentDocument.head.appendChild(style);
});
</script>But I have a question: can this ID change at some point? Is this always like this for each Zendesk instance?
-
It gives me this error, with this script.
Please sign in to leave a comment.
10 Comments