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

Hi Zen-Friends,

 

Is someone able to help me hide or freeze a specific form field form being selected (it has a default selection)?

I've tried this code from what I've seen in this thread but it's not stopping the user (me) from being able to select and open the drop down.

  //Code to stop form drop-down selection on Flex Stay Support form//
 
if (window.location.href.indexOf("formid") > -1) {
$('.form_field.request_custom_fields_fieldid_label').hide(); // Hide Requester Type
}

0


image avatar

Brandon (729)

Zendesk LuminaryUser Group LeaderThe Humblident Award - 2021Community Moderator

Hey Hannah Lucid -

 

Your code looks solid.  I would suggest ensuring that you have jquery installed and that the code is properly seated in your script.js file.  Let us know if that helps, and if not some screen shots might help us troubleshoot further.

 

Cheers,

 

Brandon

0


Brandon (729)  - You're always SO helpful Brandon. I appreciate you reaching out. 

The drop-down is still available for value selection when I put the code on the script.js 

 

0


image avatar

Brandon (729)

Zendesk LuminaryUser Group LeaderThe Humblident Award - 2021Community Moderator

Thank you for your kind words, Hannah Lucid -

 

This might sound silly, but have you tried creating an end user profile and viewing it in the browser opposed to the preview mode? Sometimes all of the JavaScript elements don't load properly in preview, ironically. 

 

You might also try disabling any browser extensions that might be interfering with your script.

0


I have followed the instructions and made it work - the Subject field gets filled, and both Subject and Description are hidden.

The only issue I have is that Description field is not showing the text I am trying to get in.

 

If I do a console.log($('#request_description').val()); - like Andy Pitts - I do see the value shown in the console log, but NOT in the Description field. I can't submit the form, as it says the Description field is empty.

 

If I remove wysiwyg=true from the new_request_page.hbs, then it works, but I do want the users to be able to paste pictures into the description field.

 

So is there any way I can make this work without removing wysiwyg=true?

 

Here is my code:

 

$(document).ready(function() {
 var ticketForm = location.search.split('ticket_form_id=')[1];
 if(ticketForm == xxxxxxx) {
   $('#request_custom_fields_xxxxxxx').change(function () {
    
     
     var fieldchoice = $('#request_custom_fields_xxxxx').val();
          if (fieldchoice == ('request_study_number')) {
     
  
   $('#request_subject').val('Request new study number');
              console.log($('#request_subject').val());
   $('#request_description').val('Test Veeva description.');
            console.log($('#request_description').val());
         $('#request_subject').parent('.request_subject').hide(); // Hide subject
      $ ('#request_description').parent('.request_description').hide(); 
            
       
     } else {
        $('#request_subject').val('test subject blank');
       console.log($('#request_subject').val());
   $('#request_description').val('test blank'); 
       console.log($('#request_description').val());
            $('#request_subject').parent('.request_subject').show(); 
      $ ('#request_description').parent('.request_description').show(); 
      
            }})}});

 

 

I have added <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script> to the document_head.hbs

0


Brandon (729)  - Thank you for your help!

I added the code, went into an incognito window, and tested the field. It was still available for selection. 

Am I missing an VAR statement before the code above? Do I need something added to the style.css code? 

I added a jquery code to the header page as mentioned in the article you linked. I'm at a loss.

 

0


Just an update:

I found that instead of using a script code to hide a specific field form, I used a css/html code on the style.css page:
 

/***** Hiding FIELD NAME field on Form *****/
.request_custom_fields_customfieldid {
     display: none
}


Inspiration: https://support.zendesk.com/hc/en-us/community/posts/5086062222874-In-guide-in-forms-put-ticket-fields-side-by-side

0


image avatar

Brandon (729)

Zendesk LuminaryUser Group LeaderThe Humblident Award - 2021Community Moderator

Glad you got it and thanks for sharing the solution!

0


This thread is SO long at this point, I find I am lost. Any help is much appreciated!! 

 

I am hoping to just accomplish the basics - Fill my Subject line based on a custom field dropdown, selected by my end user. I have been attempting to edit my code with no success. 

0


Nate Hales - This may be convoluted, by here is how I would achieve this. Someone with more experience, feel free to chime in!!
 

Here is the code to Hide your Subject field and enter a specific value. Put this at the bottom of your script.js:


//Hide and auto-fill subject line on theFORMNAME form//
var ticketForm = location.search.split('ticket_form_id=')[1];

if(ticketForm == PUTFORMIDHERE) {
$('.form-field.string.optional.request_subject').hide();// Hide subject 
$('.form-field.string.required.request_subject').hide(); // Hide subject
$('#request_subject').val('PLACEHOLDERSUBJECT'); // Autofill subject
}

 


From there, you can create a webhook that updates the ticket when it's created from this form. Here is the code to update the subject line:

         Webhook Setup:

      Trigger Webhook Code:

{"ticket": {"subject": "{{ticket.ticket_field_customfieldidhere}} - Text can also go here"}}

 

I hope this helps!

 

 

0


Brandon (729) Do you know how to hide the Attachments option if a specific drop down is selected in a Zendesk Form?

 

Example
(Field ID is 123456789)
If Field Value is option 2, then show Attachments
If Field Value is Option 2, then hide Attachments

 

I got as far as hiding the Attachments but I need some conditional formatting that I can’t do in Zendesk Admin

 

jQuery for hiding attachments that I used that I found on this thread….
$('.form-field label:contains("Attachments")').hide(); // Hide label for Attachments
$('#upload-dropzone').hide(); // Hide upload box for Attachments

0


image avatar

Brandon (729)

Zendesk LuminaryUser Group LeaderThe Humblident Award - 2021Community Moderator

Hey Juliana O'Brien -

 

@Thomas (internalnote.com)  came up with this solution on another thread:

document.addEventListener('DOMContentLoaded', function() {
    document.querySelector('#request_custom_fields_1234567890').addEventListener('change', function() {
        if (this.value === 'Option 2') {
			$('.form-field label:contains("Attachments")').hide(); // Hide label for Attachments
			$('#upload-dropzone').hide(); // Hide upload box for Attachments        }
    });
});

0


Brandon (729) Thank you!!! Appreciate the help <3

0


How can I hide “Your email address field” in the form?

0


image avatar

Ifra Saqlain

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

Hi Dave Naishal,

 

Go to your Admin center > Objact and rules > Forms > Select your Form (in which you  created and added Email address field) > Open that Form > Remove the field you want.

 

 

 

Screenshot for the same:

 

 

Thanks

1


Can I hide “your email id” field as well?

0


Hi all - I was able to successfully autofill and hide my description field, but when some end users try to submit a ticket, the “Description: cannot be blank” error" flashes and does not let them submit the ticket. This is only happening to some people, not all. Has anyone dealt with this before? Is there an error in the code or is it something with the end user? Thanks in advance!

0


Anybody successfully modified this for Copenhagen v4?

0


How to do it in Templating API v4

0


Hi All, 

 

very new to Zendesk and not very strong at coding. I'm basically looking for a way to hide the Subject, Attachment and Description fields on a specific form.

 

Using Copenhagen Theme version 4.1.0

Templating API v4

 

I've landed on this but not sure exactly where I should insert the code. Can anyone give me some directions please?

 

var ticketForm = location.search.split('ticket_form_id=')[1];

if(ticketForm == 28674919414929) {
$('.form-field.request_subject').hide(); // Hide subject
$('.form-field.request_description').hide(); // Hide description
$('.form-field.string.optional.request_cc_emails').hide();// Hide CCs 
$('.form-field label:contains("Attachments")').hide(); // Hide label for Attachments
$('#upload-dropzone').hide(); // Hide upload box for Attachments
$('#request_subject').val('New EAP Appointment Request'); // autofill subject
$('#request_description').val('See details in the fields to the left'); // autofill description
}

 

I've basically added it at the bottom of my Script.js file

0


1


Hi, everything was working and then we changed theme. I copied the code from script.js and the one from document_head.hbs

 

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>

 

Is it supposed to work with all the themes? I don't understand why it was working before and not anymore this time.

0


Thank you Jan,

 

I am following that post. I hope there is a solution

0


It seems that since latest Zendesk update templating v4 that was released last July, this needs to be done in new_request_page.hbs instead of script.js. I have a support ticket on this.

0


Seems like since the implementation of Copenhagen 4.2.7 (or earlier) old methods of hiding and auto-populating Subject line and Description field no longer work. 

 

Please, if anyone has any advice on how to hide and auto-populate the Subject line and description field of a specific form, I'd greatly appreciate it. 

0


Please sign in to leave a comment.