Recent searches


No recent searches

How can I disable the subject and description fields from the request form?



Edited Feb 07, 2025


9

235

235 comments

image avatar

Ifra Saqlain

Zendesk LuminaryMost Engaged Community Member - 2022Most Engaged Community Member of The Year - 2021Community Moderator

@David Jetter, 

Currently in your code, remove it:

document.querySelector('.form-field.string.optional.request_subject).style.display= "none";
'none';

 

Replace that line of code with given below:

document.querySelector('.form-field.string.request_subject').style.display= "none";
'none';

0


Ifra Saqlain That did the trick, thank you so much for helping with this!

0


image avatar

Brett Bowser

Zendesk Community Manager

Thanks for jumping in to help with this one Ifra! Glad you were able to ge this working on your end David :)  

0


image avatar

Ifra Saqlain

Zendesk LuminaryMost Engaged Community Member - 2022Most Engaged Community Member of The Year - 2021Community Moderator

My pleasure Brett Sir! and I'm glad that it's working for David :)

0


Ifra Saqlain Shifting thought, do you know how to add fields to the subject without the subject being hidden? Looking to have the end user add the subject themselves, and then after clicking submit adding two dropdown custom fields to the subject line. I currently have: 

 

But this doesn't work. Link to page is here. The two custom fields in question are dropdowns. Thanks in advance for any help you can offer!

0


image avatar

Ifra Saqlain

Zendesk LuminaryMost Engaged Community Member - 2022Most Engaged Community Member of The Year - 2021Community Moderator

@Teresa, try this code, add it to your script file --

 if($("#request_issue_type_select").val()=="360003074611") {
$('#request_subject').keyup(function(event) { 
    function clickB() {
       var a = $("#request_custom_fields_1900000313287").val();
       var b = $("#request_custom_fields_360046758831").val();
       var c = $("#request_subject").val();
      $("#request_subject").click(function(e){
        e.preventDefault();
        $("#request_subject").val( a + " " + b + " " + c);
      })
    }
    clickB();
  });
  }


Note: Add your IDs of the form and fields.

 

i). When you have done with the code.

ii) Go to that form page > select value in the both dropdowns.

iii) Go to the subject field and type your title.

iv) Double-click on the subject field after writing the title.

v) Both dropdown field values will be added in the subject field.

 

Hope it helps you.

If any queries feel free to ask :) 

0


Do you have please any insights on the email address field? How can I move it, for instance, placing it in the third position, or how can I hide it from the form?

0


image avatar

Gabriel Manlapig

Zendesk Customer Care

Hi Walaa,
 
Email address, or "Your email address," is the part where the requester of the ticket is identified, and it is a mandatory field when submitting a request via Zendesk Guide. I'm afraid this field is hardcoded on our backend and can't be moved or hidden from the ticket form.
 
I hope that answers your question. Thank you!
 

1


New to Zendesk - so please be nice :) 

I am in the process of setting up forms for different option and came across this and wanted to see if someone could help. 

I am just looking for a basic example of how to hide the Description and Subject fields for certain forms i create. I know how to get the form ID already - just need help with a template. 

Thanks! 

0


image avatar

Brandon (729)

Zendesk LuminaryUser Group LeaderThe Humblident Award - 2021Community Moderator

Hey Geoff Ludwig,

Welcome to the cool kids club!  To achieve your result, you can follow the instructions here but with a few lines of supplemental code.  In this case, we are going to wrap the code that hides the fields inside an if statement that looks for the form id(s).

To hide the subject and description fields using Javascript or jQuery

  1. Ensure that you've imported a jQuery library if you want to use jQuery statements in a theme in place of vanilla JavaScript.
  2. In Guide, click the Customize design icon () in the sidebar.
  3. From the theme you want to work with, click Customize.
  4. Click Edit code and add the example code below in the script.js template.
    var formID = location.search.split('ticket_form_id=')[1];
    if(formID == "TICKET_FORM_ID_1" || formID == "TIDCKET_FORM_ID_2"){
    $('.form-field.string.optional.request_subject').hide();// Hide subject
    $('.form-field.string.required.request_subject').hide(); // Hide subject
    $('.form-field.request_description').hide(); // Hide description
    $('#request_subject').val('test subject'); // Autofill subject
    $('#request_description').val('test description'); // Autofill description
    }
  5. Select Publish.

The created tickets will have the subject and description fields auto-populated but only for those specific forms.  You might also find the JavaScript Cookbook helpful.

Let me know if you have any additional questions, and if you need more personalized assistance, feel free to drop me a line and schedule a free consultation with our team.

Brandon

1


One thing I would add, Brandon (729), is that this method does not work so reliably.  Due to a bug in ZenDesk, if you submit a ticket form with errors (mandatory field not filled out, etc.), the page will refresh with the current form open, but the URL will change - it will no longer display the form ID in the URL, and your JS code will be useless.

The only workaround I have found so far is to detect for a particular field on the page, rather than using "ticket_form_id=", and if that field exists, then run whatever conditions you want.  Of course, you would need to make this "special field" and only use it on the form you need it on, and then perhaps hide it with JS, but otherwise you will have unreliable JS.  Try it out yourself if you don't believe me :)

1


image avatar

Brandon (729)

Zendesk LuminaryUser Group LeaderThe Humblident Award - 2021Community Moderator

Hey Mark,

That's a good call out.  We've had some luck using Mutation Observer to scan for changes in those hidden fields, but that does require a far deeper configuration of the JavaScript.

Brandon

1


Thanks Brandon and Mark! 

 

I will be trying this now - stay tuned!! 

0


I think i am missing something - hopefully you guys can help.  I hit publish on both screens and the subject is still showing.  HELP! :)

 

I added the code to document_head.hbs per this article you referenced. 

 

And i added the code you supplied to the script.js at the bottom (not sure if that matters). 

0


image avatar

Brandon (729)

Zendesk LuminaryUser Group LeaderThe Humblident Award - 2021Community Moderator

Very Close!

In your second part - the first two lines should read

var formID = $("#request_issue_type_select").val();

if (formID == "22729390264724") {

The first line grabs the current form ID from the URL; the second checks your target form against that variable.  

0


Thanks for the quick response... I changed and i am still seeing the same issue. 

 

0


Brandon (729) - did I do something on the code above? 

0


image avatar

Brandon (729)

Zendesk LuminaryUser Group LeaderThe Humblident Award - 2021Community Moderator

Hey Geoff Ludwig -

From where I'm sitting that looks good - but there's quite a few reasons that might break.  Someone else from the community might be seeing something I'm not though.  Alternatively, if you'd like to hop on a quick call you can grab time with me here next week.

Cheers,

Brandon

0


Brandon - the grab time with me here  hyperlink is not working.

Can you provide something else?

0


image avatar

Brandon (729)

Zendesk LuminaryUser Group LeaderThe Humblident Award - 2021Community Moderator

Hey Geoff - Sorry about that - you can reach me at https//lp.729solutions.com/free-zendesk-checkup - you may have to copy/paste into your browser.  Looking forward to it!

0


image avatar

Brandon (729)

Zendesk LuminaryUser Group LeaderThe Humblident Award - 2021Community Moderator

Hey Geoff,

Closing the loop here - we were able to confirm your JS implementation and obscure the subject line from the end-user form by going to Admin Center > Ticket Fields > Subject and setting to "Agent Only."  Glad to see that we were able to get things sorted for you!

Brandon

1


Thank you sir! Excellent assistance! 

0


I have tried to change the "Your email address" label but didn't work, can any one guide how can I do this?

0


image avatar

Ifra Saqlain

Zendesk LuminaryMost Engaged Community Member - 2022Most Engaged Community Member of The Year - 2021Community Moderator

Hi Shahid Iqbal,

 

Add the given line to your script.js file at the bottom area.

document.querySelector('.form-field.request_anonymous_requester_email > label').innerHTML= "YOU TEXT HERE";

 

I have tested it and it's working. If any issue let me know I'll change the class (request_anonymous_requester_email).

Thanks

 

1


Yes, that worked for me. Thank you so much

0


Hi

 

With the help of this article and comments I've been able to get the Subject and Description fields to autofill based on the ticket form being used. On the first attempt this works as expected but if I then select a different form from the dropdown the Description field reverts to being blank. The Subject field works perfectly every time. If I wait about 15 seconds before selecting a different form, the Description field does autofill but if I change the selected form any quicker than that it is always blank.

 

For troubleshooting, I have used console.log($('#request_description').val()) to check what value the field has and even when the Description box is visibly empty "val()" is showing the correct value (albeit without the surrounding <p></p> tags). However, it is not enough to allow the form to be submitted because it returns with the error that the Description field needs to be completed.

 

It feels like a problem related to the rich text editor of the Description field.

 

Any advice on how I can get this to work consistently like the Subject field?

 

Thanks in advance

0


Hi

I have hidden the Description field from the end user and auto-populate this with information the agents need to provide before escalating to another function within the business. This works well apart from one drawback, the Description field is visible to the End User when they are viewing their tickets in the Requests page. 

Is it possible to hide this description from the end user completely?
 

Open to suggestions on how to get round this. I've also tried populating it with values from custom fields but that didn't work, the Description field wouldn't populate.

 

Thanks

 

James

0


Hi James Skene !

 

Since end users are the ones submitting tickets, the description would go in as a public comment. One thing to explore might be to have a generic “We've received your ticket” (or something similar) message post as the description, then once the ticket is received, have a trigger with a webhook that posts an internal note to the ticket with all the details the agent needs.

 

Hope this helps!

Sam

0


Thanks Sam!

 

Hmmm that could be a good fallback thank you. Are you aware of any way to populate the Description field with custom field values, similar to how we to do it for the subject? I have the tried the same code, replacing "#request_subject" with "#request_description" but to no avail

 

Thanks

 

James

0


James Skene  Are you trying to populate the data from a custom field using JavaScript on the submission form itself? Do you have a copy or screenshot of the section of code you are attempting to use (but isn’t working)? 

0


Please sign in to leave a comment.