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

Have more questions? Submit a request

69 Comments

  • Elanor Riley
    Comment actions Permalink

    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
    Comment actions Permalink

    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
    Comment actions Permalink

    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
    Comment actions Permalink

    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
    Comment actions Permalink

    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
    Comment actions Permalink

    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
    Comment actions Permalink

    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
    Comment actions Permalink

    Hello

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

    0
  • Dave Foster
    Comment actions Permalink

    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

Please sign in to leave a comment.

Powered by Zendesk