Disabling the subject and description fields on the new request form in Help Center

Return to top
Have more questions? Submit a request

83 Comments

  • Elanor Riley

    You're welcome! And yeah you're right I didn't even notice your use of .label() which isn't valid for jQuery, so that would totally explain why it wasn't working. Glad that we could help you find a solution :)

    0
  • Jamee Lewis

    Hi, 

    Hoping someone can help me. We are trying to hide the subject and description on just one of our forms and have them populate with details from the form upon submission.

    However, the description on other forms is being overridden when an employee submits their requests. Below is the code we have used:

    Any help would be great!! 

     

    //Form Submit

    $(document).submit(function() {

    //only run on specific form

    if (window.location.href == "https://INSERTDOMAIN.zendesk.com/hc/en-us/requests/new?ticket_form_id=360000041815")

    {

    //set a string to equal the custom field value

    var subjectstring1 = $("#request_custom_fields_360000255215").val();

    //set subject to equal a string including field value string

    $('#request_subject').val("Employee Departure" + " - " + subjectstring1);

    }

    {

     //set a string to equal the custom field value

    var subjectstring1 = $("#request_custom_fields_360000255215").val();

    //set description to equal a string including field value string

    $('#request_description').val("Employee Departure" + " - " + subjectstring1);

    }

    });

    //End Form Submit

     

      //adding a disclaimer

     

      var selected = $('#request_issue_type_select option:selected').text();

    if (selected == "Departure Request") {

    $('div.request_ticket_form_id').append('<p></p>');

      }

      //end disclaimer

     

      //hide system fields based on ticket forms (change subdomain and form id)

     if (window.location.href == "https://INSERTDOMAIN.zendesk.com/hc/en-us/requests/new?ticket_form_id=360000041815") { 

       $('#request_subject').val('"Employee Departure" + " - " + subjectstring1');

          $('#request_description').val('"Employee Departure" + " - " + subjectstring1');

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

          $('#request_description').parent('.request_description').hide();

    }

    0
  • Socorro Fernandez
    Community Moderator

    Hi Jamee Lewis

     

    It looks like the part of the code where it is updating the description is not within the if statement so its going to run for every form:

    //Form Submit

    $(document).submit(function() {

    //only run on specific form

    if (window.location.href == "https://INSERTDOMAIN.zendesk.com/hc/en-us/requests/new?ticket_form_id=360000041815")

    {

    //set a string to equal the custom field value

    var subjectstring1 = $("#request_custom_fields_360000255215").val();

    //set subject to equal a string including field value string

    $('#request_subject').val("Employee Departure" + " - " + subjectstring1);

    }

    {

     //set a string to equal the custom field value

    var subjectstring1 = $("#request_custom_fields_360000255215").val();

    //set description to equal a string including field value string

    $('#request_description').val("Employee Departure" + " - " + subjectstring1);

    }

    });

    //End Form Submit

     

    I believe you would want to move the update description field portion within the if statement where you are updating the subject field with the custom field value and it should resolve that issue. Here is just the form submit update that worked with testing on my end:

    //Form Submit

    $(document).submit(function() {

    //only run on specific form

    if (window.location.href == "https://INSERTDOMAIN.zendesk.com/hc/en-us/requests/new?ticket_form_id=360000041815")

    {

    //set a string to equal the custom field value

    var subjectstring1 = $("#request_custom_fields_360000255215").val();

    //set subject to equal a string including field value string

    $('#request_subject').val("Employee Departure" + " - " + subjectstring1);

    //set description to equal a string including field value string

    $('#request_description').val("Employee Departure" + " - " + subjectstring1);

    }

    });

    //End Form Submit

    Please let me know if you have any questions or run into any other issues

    0
  • Juan Espinosa

    Hi There Socorro Fernandez 

     

    Hope you are able to help, is there a code i can enter on our script.js to customize the description to our users on our Description box? 

     

    Thanks for your help! 

    0
  • Dave Foster

    There's one thing that is a big downer about using this code to hide the system fields. If you have any Required Fields, and the customer doesn't fill it out, once the system reloads the page to show the warning that the field cannot be blank (or whatever the requirement is), it drops the ticket form id from the URL. Once this happens, all the hidden fields will show back up, including any custom text you've added to said fields.

    0
  • Doug Shaner

    I was able to successfully hide and auto fill several system fields, but I'm having trouble with custom fields.  

     

    Here is the code I used to hide a custom drop down field:

    Hide category
    $(document).ready(function() {
    $(".request_custom_fields_360024163811").hide();
    });

     

    Hiding it works, but I can't figure out how to auto populate this field.  I've tried things like the following with no luck:

    $('#request_custom_fields_360024163811').val('Equipment Request'); // autofill category

    Can someone tell me how to set this drop down field to a pre-defined value?

     

    Thank you!

     

    0
  • Ed Ball

    So working with the below code I was able to get it working with a couple issues. First issue is I do not want to change the description at all. But i can not remove that part without all of it breaking. It just does nothing if I remove the 'set description' part.

    I just want the Subject to be replaced with the contents of the custom field. But even with that part of this it seems to be showing the tag of the item selected  and not the label value. The customer can see the subject, so of course i do not want the tag showing.

    How do I remove the description part and show the Value in the Subject and not the tag for it?

    //Form Submit
    $(document).submit(function() {

    //only run on specific form
    if (window.location.href == "http://(brandx).zendesk.com/hc/en-us/requests/new?ticket_form_id=360001458394")
    {

    //set a string to equal the custom field value
    var subjectstring1 = $("#request_custom_fields_360041921694").val();

    //set subject to equal a string including field value string
    $('#request_subject').val("Rollback" + " - " + subjectstring1);

    //set description to equal a string including field value string
    $('#request_description').val("Rollback" + " - " + subjectstring1);
    }
    });

    //End Form Submit

    0
  • Sirin Sezer

    Hello

    How am I going to do this in V2 without jQuery?

    0
  • Dave Foster

    You can still do this in V2, but you have to import the jQuery library in your Guide theme:

    https://support.zendesk.com/hc/en-us/articles/360037983854-Importing-or-upgrading-jQuery

    0
  • Simon

    Hello All!

    Hope you are all staying safe!

    To jump on this thread I am after a very similar thing and wondering if you can help.

    We've hidden the subject and description fields already as we are using multiple forms, however, what's happening at the moment is all new tickets are coming through with a subject of 'New Ticket' which we've defined. 

    Ideally i'd like all tickets to come through with the subject pre populated with the form name.

    For instance, we have a form called 'Disable A Customer', which i'd like for and new tickets created to enter Zendesk with a subject of 'Disabled A Customer' when this form is chosen and different subjects if other forms are chosen. 

    Can anyone advise if this is possible?

    Thanks

    0
  • Dave Foster

    Simon, you can find multiple places in this thread to do what you are asking, but it can be daunting if you aren't familiar with the jquery code being used. Please be aware, before you can use this code, you'll need to import a jquery library into your Guide theme. You can find these instructions here: https://support.zendesk.com/hc/en-us/articles/360037983854-Importing-or-upgrading-jQuery

    The following code has been formatted to do what you are asking. It will do the following:

    • Tell Zendesk whaich form to use this code for
    • Hide the Subject Line from your customers
    • Automatically enter "Disable A Customer" into the subject line

    Note the areas where you will need to enter your own company's zendesk subdomain and the ticket form number. You can find the ticket form number by going to the ticket form and copuing the number string at the end of the URL. Alternatively, you could simply replace the entire URL in the code with your URL, and will need to do so if you are outside the US.

      //custom ticket fields for Disable A User Form
    if (window.location.href == "https://YOUR.ZENDESK.DOMAIN/hc/en-us/requests/new?ticket_form_id=12345678") {
    $('#request_subject').val("Disable A Customer");
    $('.request_subject').hide();
    1
  • Ed Ball

    Why does this seemingly simple example not work for me?  It's still using the beginning of the description for the subject. I did everything above including adding the JQuery line.

    0
  • Dave Foster

    Have you imported a jquery library into your Guide Theme?

    0
  • Ed Ball

    I got this working and showing a custom field as well. The issue with it is we use dynamic content for ticket fields. it's showing the value of the item chosen and not the dynamic content version of the text. Not sure there is a way around this....  let me know if I am wrong..

    Example:

    Customer sees list with Crashing, Error Code, Install, etc..  

    Dynamic content is dc.ticket_option-crashing, __dc.ticket_option-error_code, __dc.ticket_option-install, and so on...

    So the ticket is showing Technical Support - __dc.ticket_option-error_code

     

    Since the customer can see the subject I am not sure it's usable in that form. So of the dc titles get pretty long.

    0
  • Simon

    Hello Dave,

    Thanks for your response, that's really helpful.

    Ideally, as I have a number of forms, I'd like the $('#request_subject').val("Disable A Customer"); part of the code to be pre populated with that of the form name itself rather than having to add all different form names, would this be possible?


    0
  • Dave Foster

    Simon,

    If you leave out the first "if" statement, it will populate on all your forms. But you'll only get one option for what it will say, i.e. ALL of your forms will have the subject hidden and the subject will be filled in with the same string of text. Using the if statement with the URL tells the code what form to apply the jquery to, and what to enter into the subject line.

    So, unless you want all your forms to be exactly the same, you must input the same block of code multiple times, once for each form you'll use it for, and change the URL to match said form, and customize the subject line for each.

    Notice the top line of my example had // in front. This makes that line simply a reference. You can make it say anything, so it's a good way to organize which code does what. You could have that line say //Custom code for Disable Form, and on another //Custom code for Onboarding form, etc.

    0
  • Derek Yanoff

    Hello,

    I've read through most of these comments and still cannot get this script working on my Help Center. I am trying to hide the "Subject" and "Description" fields only on one specific ticket form. I am using the theme Copenhagen (2.2.4) and I do not see "$(document).ready(function() {" anywhere in script.js.

    Let me know what I'm doing wrong.

    Thanks

    0
  • Dave Foster

    That section no longer exists in API v2. First, no matter where you put your code, you MUST import a jquery library. See my comment with a link to the instructions to do this several comments up. Also consider that spacing and format matter a lot. A wrong space or indent can mess the whole thing up. Finally, ensure that you are using the correct URL for the form in the if statement, and that you have changed your subdomain appropriately. Enter your code AFTER the section that looks like this:

      function closest (element, selector) {
    if (Element.prototype.closest) {
    return element.closest(selector);
    }
    do {
    if (Element.prototype.matches && element.matches(selector)
    || Element.prototype.msMatchesSelector && element.msMatchesSelector(selector)
    || Element.prototype.webkitMatchesSelector && element.webkitMatchesSelector(selector)) {
    return element;
    }
    element = element.parentElement || element.parentNode;
    } while (element !== null && element.nodeType === 1);
    return null;
    }
    0
  • Luke Hutchings

    So I have changed the description field name and hid the subject on multiple different forms, however, for some reason we just noticed that these changes are now not being displayed on our live forms. Why is this and what should we do to change them back? 

    We have a number of forms stating "tell us what we can help you with" and a "subject" line that does not make sense given what the form regards. Please help asap as we are doing exactly what is state in this article and it is not working. 

    0
  • Brandon Tidd
    Community Moderator

    Hi Hari Hartas - 

    The snippet of code you need is featured here: 

    https://github.com/Ajhad1/Zendesk-Web-Widget-Modifications

    Please note the suggested modification: 

    This article has more information.  Hope this helps!

    0
  • Samuel Mosher

    Does anyone have a way to capture all entered values on a ticket form and inject that into the description field? We are looking for a cleaner setup without having to create a litany of triggers. One form in particular has ~200 conditioned fields on it, so that would amount to a fair amount of bloat.

    0
  • gil alvarez

     

    Ok, I also have a similar requirement, where I want the subject/description fields hidden, but then populated with something from custom fields on form submit. The code below actually works fine when I'm in preview mode. But it doesn't work when I push the theme live.

    Now, the other thing is that it breaks in different ways in different browsers. On Windows-FF, the fields are hidden (the below executes), but on form submit none of that code executes. I did verify via "view page source" that the form is called "new_request".

    On mac-Chrome, jquery is simply not found. I get the "'$ is not defined" error. But it's clearly there. Again I can see it via page source. No errors in the network log in terms of doing the GET to get the jquery file.

    Any ideas would be much appreciated..

    Thx.


    $('.form-field.string.required.request_subject').hide();
    $('.form-field.string.optional.request_subject').hide();
    $('.form-field.request_description').hide();
    $('#new_request').submit(function(e){
    var temp = $('#request_custom_fields_360052144814').val() + " " + $('#request_custom_fields_360053124453').val();
    $('#request_subject').val(temp);
    $('#request_description').val(temp);
    });
    0
  • gil alvarez

    To reply to my own comment, a few things to clarify:

    • I was able to repro fine in preview mode, by switching the user to "anonymous".
    • The submit callback issue is due to recaptcha (since this only appears with "anonymous"). Apparently recaptcha takes over form submittal and any callbacks registered elsewhere are ignored.
    • The "$ is not defined" error is intermittent. It doesn't happen all the time. I can keep submitting a form w/o filling required fields, getting an error, and everything is fine. When I do it several times (6, 8, it varies) then I get the "$ is not defined" error. And I've seen this on different browsers (Safari, chrome), and on both windows & mac. No idea why this is happening.
    0

Please sign in to leave a comment.

Powered by Zendesk