Question
How can I hide or remove the subject and description fields on the submit a request form in the help center?
Answer
It's possible to hide the subject from your request form, but it's not possible to natively hide the description field.
To hide the subject field from the request form
- Go to Admin Center > Objects and rules > Tickets > Fields.
- Open the Subject field.
- Under Permissions, select Customers can view.
- Select Save.
Customers won't see the subject field in the request form, but the field is visible in the customer portal.
When you use the Customers can view permission, the description of the ticket becomes the subject of the ticket. However, you can use Javascript or jQuery to autofill and hide both subject and description fields.
To hide the subject and description fields using Javascript or jQuery
- Ensure that you've imported a jQuery library if you want to use jQuery statements in a theme in place of vanilla JavaScript.
- In Guide, click the Customize design icon (
) in the sidebar.
- From the theme you want to work with, click Customize.
-
Click Edit code and add the example code below in the script.js template.
$('.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 - Select Publish.
The created tickets will have the subject and description fields auto-populated as in the example below.
163 Comments
@Vamshi R,
Use the given code:
Ifra Saqlain I used the same code which you shared with me, but still its asking for your email address field. Below is the code which i used.
Vamshi R,
You forgot to add '#' in:
and, you only added the number
Code should be :
Ifra Saqlain Deployed the same code which you shared, but still i am getting same error.
var ticketForm = location.search.split('ticket_form_id=')[1];
if(ticketForm == 10322663005972) {
$('.form-field.request_description').hide(); // Hide description
$('.form-field.request_anonymous_requester_email').hide(); // hide your email address
$('#request_description').val('Description of Incident Activity'); // autofill description
$('#request_anonymous_requester_email').keyup(function(e) {
var mailId = $(this).val();
$('#request_custom_field_10475189470356').val(mailId);
});
}
If you have sometime can we connect through Zoom meeting to go through this code.
All these tweaks are fine, except for the fact that if the customer forgets to fill in a mandatory field, the page resets to load the warning messages and you lose the ticket id in the url, rendering your custom script useless when trying to customise a specific ticket form ID.
Does anyone have a fix for this?
So you can try this snippet instead of form ID:
I simply tested it by console message.
Please try and let me know :)
And,
This is not the way to give feedback, be humble PLEASE :)
Thanks
Many thanks Ifra!
That works much better than using ticket form numbers.
I see that this works because when the form id gets removed during the warning message refresh, the previously selected ticket name is still selected, so we use that as the hook and not the ticket id.
Here is my working code that allows you to change the '(optional)' label text on the attachment upload area to something else:
Is there a way to change an input field from optional to required? I was able to change the optional/required class names of input fields, but you don't get the warning messages if the fields are empty at time of submitting. What would be the code to setup a custom validator on a field, to check it is filled in and return a custom message if it isn't filled in?
Hi Dave Potts,
This is the solution: https://support.zendesk.com/hc/en-us/community/posts/4409515169946-Requiring-a-ticket-attachment-if-a-particular-dropdown-option-is-selected
and also, I'm sharing with you some screenshots below.
i). Select 'Admin Center' in the dropdown list .
ii). Go to the 'Objects and rules' Option in the left sidebar, click on 'Fields' option now you will have your all fields of tickets. Select you field which you want to make 'Required'.
iii). After reaching inside of your field, check the 'Required to solve a ticket' option.
Thanks
Ifra Saqlain not sure if you can help with this one, or if this is the right place to ask. We have a field that is an urgency value. Is there any way to have the field selection populate at the beginning of the ticket subject? Basically, amend what the end user states for the subject to include this value.
Info:
Form: (ticket form)
Field ID: (ticket field)
Thank you in advance for any help you can provide!
Hi Nicole,
I tried to get the solution of your query but I think it's not possible by my side.
Thanks
Ifra Saqlain thank you for trying! Back to the drawing board. :)
Hello, is there someone that can help me. I am trying to hide the attachments/upload ticket field box on one forms page and having trouble coding for this. I was able to add a document event listener to hide the description field box, but cannot get it to work for the attachments field id.
Here is the code I am using for the description field box:
document.addEventListener("DOMContentLoaded", function () {
function hideDescriptionField(){
var descriptionWarpper = document.querySelector('.form-field.request_description');
var descriptionField = document.querySelector('#request_description');
descriptionField.innerHTML = 'PostSurvey';
descriptionWarpper.style.display= "none";
}
}
hideDescriptionField();
});
Hey Marsy Franco (admin),
There was an extra curly bracket which I removed, now use the below code:
Please sign in to leave a comment.