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

0


image avatar

Ifra Saqlain

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

@Mark Z, if possible share your HC URL where you are working. 

0


Unfortunately I can't share it as it is being used in production with user authentication enabled.  But it is a standard Date field, so you should have the same issue no matter where it is being used.  (namely, which event handler can we use for when the user chooses a date in the Date field?)

0


image avatar

Ifra Saqlain

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

No problem, I'll look at it by adding date field to my form.

0


Ifra Saqlain I hope you can help me out on my issue. 

  • On our request page we have one field is hard coded in the script. Below highlighted field should be removed from this form.
  • I want hide Description field for only one form.

 

0


image avatar

Ifra Saqlain

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

Hi Vamshi R,

Add the code to your script.js file but you need to add your form ID and field ID or class name as I mentioned below where to add.

 

To hide description field:

 if (window.location.href.indexOf("00000000") > -1) {

// Hide description field
document.querySelector('.request_description').style.display= "none";
  }

Note: Remove 00000000 and add your form ID for which form you want to hide.

 

To hide the Email address field:

if (window.location.href.indexOf("00000000") > -1) {

// Hide description field
document.querySelector('.request_description').style.display= "none";
  }

Note: Remove 00000000 and add your form ID for which form you want to hide.
Remove .request_description and add field ID or class.

 

You can find your form ID in your search-bar.

 

Team

0


Hi Ifra Saqlain 

   I just used below code and now i am able to hide Description and your email address field. 

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').val('vamshi.r@pro-vigil.com'); // autofill your email address
}

But i have one more concern, how can i populate a custom ticket field data on your email address field. Below is the screenshot of the field which i need to populate.

 

0


It seems to me that ZenDesk disabled many functions of jQuery.  For example not all event handlers can function with standard text fields or labels (like mouseenter), and some fields like Date do not allow any events handlers at all (that I have tried).

It would be nice to get some documentation about this from ZenDesk but I have not found any.

0


image avatar

Ifra Saqlain

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

@Vamshi R,

Use the given code:

$('EMAIL-FIELD').keyup(function(e) {
  var mailId = $(this).val();
$('PRIMARY-EMAIL-FIELD-ID').val(mailId);
});



Note: Remove
EMAIL-FIELD
add your field id of
custom ticket field


Remove
PRIMARY-EMAIL-FIELD-ID

add your field id of
email address field id

0


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.

 

0


image avatar

Ifra Saqlain

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

Vamshi R,

 

You forgot to add '#' in:

 $('request_anonymous_requester_email').keyup(function(e) {

 

and, you only added the number

$('10475189470356').val(mailId)

 

Code should be :

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

if(ticketForm == 10322663005972) {

// YOUR OTHER CODE

  
  $('#request_anonymous_requester_email').keyup(function(e) {
  var mailId = $(this).val();
  $('#request_custom_field_10475189470356').val(mailId);
  });
}

 

0


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.

0


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?

0


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:

jQuery( document ).ready(function() {

if($("#new_request a.nesty-input").is(':contains("Register my Product")')){
$('.form-field label:contains("Attachments") span.optional').empty(); // Remove (optional) label for Attachments
$('.form-field label:contains("Attachments") span.optional').append("- *Please upload a copy of your order receipt. Thank you."); //Set new label
}  
  
});

 

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?

0


image avatar

Ifra Saqlain

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

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

0


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!

0


image avatar

Ifra Saqlain

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

Hi Nicole, 

I tried to get the solution of your query but I think it's not possible by my side.

 

Thanks

0


Ifra Saqlain thank you for trying! Back to the drawing board. :) 

0


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

0


image avatar

Ifra Saqlain

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

Hey Marsy Franco (admin),

There was an extra curly bracket which I removed, now use the below code:

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

0


Ifra Saqlain

Below is a snippet of code that we use to hide the subject, but then also add a field on the form to the hidden subject line: 

  $("#request_custom_fields_12345").keyup(function(event) { 
var a = $(this).val();
 $("#request_subject").val(a + " Request");
});
  $('.form-field.string.required.request_subject').hide();

I'm trying to figure out how to add two additional fields to the subject line, in addition to the one already added, but can't seem to make it work. Would you happen to have any ideas? Ty!

 

 

0


image avatar

Ifra Saqlain

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

Hi Teresa, try this code snippet:

 $("#request_subject").val(" Request"); 
$("#request_custom_fields_1234").keyup(function(event) {
  var a = $(this).val();
   $("#request_subject").val(a + " Request"); 
});
$('.request_subject').hide(); 

0


Hi Ifra Saqlain! That looks like it's only one custom field added to the hidden subject, which is how we currently have it working. What I need is to have 2-3 custom fields added to the subject. Something along the lines of 

var a = custom field 1
var b = custom field 2
var c = custom field 3

subject = .val(a  + " " + b + " " + c + " Request")

I've tried a couple different pieces of coding and can't make it work. 

0


image avatar

Ifra Saqlain

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

Okay, so remove previous code and use this one,  it's working as you wanna do:

$("#request_custom_fields_0000000000,#request_custom_fields_1111111111,#request_custom_fields_222222222").keyup(function(event) { 
var a = $("#request_custom_fields_0000000000").val();
var b = $("#request_custom_fields_111111111").val();
var c = $("#request_custom_fields_22222222222").val();
   $("#request_subject").val(a +" "+ b + " "+c+" " + " hey"); 
});

$('.request_subject').hide(); 


000000000 -- My custom text field IDs, your custom fields have different ids, so update those.
111111111 -- My custom text field IDs, your custom fields have different ids, so update those.
22222222 -- My custom text field IDs, your custom fields have different ids, so update those.

 

Thanks

0


Thanks, Ifra Saqlain! I just tried this code and it still only pulls in the first custom field into the subject. Custom field 2 and 3 are missing, but it does have the " hey" at the end of the subject line on the ticket. That was the same issue I was having. Puzzles me for sure!

Form link if you'd like to have a look. 

0


image avatar

Ifra Saqlain

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

@Teresa, I tried to open the form but it requires Microsoft account credential to sign-in, and I tested the code in my sandbox; that's working fine.

 

See this screenshot: Subject field pulls all three values of Custom Fields --

 

 

 

Teresa, do one thing, go to the preview mode of your theme and check the console, if there is any error, share that screenshot.

 

0


Not positive which way you wanted me to check, so I have screenshots of both. First, when logged in and looking at the form, there are no errors, but some warnings: 

 

 

Then, when logged into Guide, go to the eye, then customize, I have the preview of the HC showing, I see this: 

 

I hope one of these are what you were looking for. Thank you!!

0


Ifra Saqlain I just had a thought. Only one field is pulling in. That field is a text field. The other two are dropdowns and they don't add to the subject. Would the type affect anything? 

0


image avatar

Ifra Saqlain

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

Nicole, when I select an option in dropdown, subject field does not afftect even after clicking both dropdown field but when I write something in textfield (at the end), subject field does affect with the both dropdown's selected values.

I tried few ideas but but nothing is working.

0


Hi Brandon (729)

The user can still see the hidden field when I try the following code, it doesn't seem to work for me. Please, could you help?

 

for (const el of document.getElementById('form').querySelectorAll("[required]")) {
  if (!el.reportValidity()) {
    return;
  }
}

0


Please sign in to leave a comment.