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

Return to top
Have more questions? Submit a request

108 Comments

  • Kendall Clayton

    Hello! I am trying to populate a subject line based on the responses in two fields. The first field works just fine as it is a drop down, but I would also like to autofill with a second field that is text so that the subject reads like: 

    Form Name: "Custom Drop Down" for Customer Account Number "Text"

    1500004202322 is the custom drop down field

    1500002723962 is the text field

    Currently I have the following code and it is not working:

    <script>
    //autofills subject with drop down value of request topic and does so in this format Form Name: Value
    $(document).ready(function() {
    //field information to match with subject this one is internal support disposition
      var issuePickerTicketFieldID = 1500004202322;
    var ticketFormID = location.search.split('ticket_form_id=')[1];
    var ticketFormTitle = $('select#request_issue_type_select > option:selected').text();

    var issuePickerTicketFieldID = 1500002723962;
    var ticketFormID = location.search.split('ticket_form_id=')[1];
    var ticketFormTitle = $('text').text();


    if (ticketFormID == 1500000387101) {
    $('.form-field.request_subject').hide(); // hide subject
    $('#request_subject').val(ticketFormTitle);
    $('#request_custom_fields_' + issuePickerTicketFieldID).on('change', function() {
    var issue = $(this).next('a.nesty-input').text();
    $('#request_subject').val(ticketFormTitle + ': ' + issue + issue);
    });
    }

    });
    </script>

    0
  • Jeff Dodge

    I was able to get this to hide my custom field by using the code that was in the answer but when I go to my help center via my mobile device the custom field that is hidden on the desktop shows up on my mobile device.   Is there a different code that I need to use to have it hide on the mobile device?

    Thanks,

    Jeff

    0
  • Janaya Cassidy

    Good Afternoon!

    I'm wondering if anyone could help me with the correct code to change the 'Description' field title to a preferred alternative title e.g. Additional Information/Reason. This would allow us to customize the field and remove a similarly named field on a couple of the forms and avoid duplication. 

    Thank-you!

     

    0
  • Chris

    thanks

    If I want to apply it like below,
    Do I need to change script.js? Or which file should I change?

    ===========================================

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

    if(ticketForm == 215063) {
    $('.form-field.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
    }

    0
  • Kuldeep Patidar

    Hi Chris,

    That's correct - paste your code to line 10 before function closest (element, selector).

     

    0
  • TAN BING

    Dear All,

    I am able to set value for Subject by below script but unsuccessful for Description. Would you please help me. I was stuck here few days already. Tks very much for your help first.

    The end-user interface as below.

    The code in script.js as below.

    0
  • TAN BING

    Btw I find the "request-description" field is inside iframe as below. How can we assign a value by add coding in script.js

    0
  • Ifra Saqlain
    Community Moderator

    Hey,

    I tried to solve for your first asked question:

    I am able to set value for Subject by below script but unsuccessful for Description.

     

    Ans. You can change the description easily as you have done in your code.

    1). Add jquery library on your document_head.hbs file.

    2). Add the script code on script.js file.

     

    3). Output is:

     

    Make sure the console tab into your inspect tool should be clear if there are any issue then may be that's the reason because it happens, when the console shows error for single code/line/variable in the script then below code of that code/line/variable don't work.

    Do one thing, comment all your custom code and just leave uncomment only the line you have written:

     $('#request_subject').val('test subject'); 
    $('#request_subject').css('color', 'red'); 
    $('#request_description').val('test description'); 

     

    now test working or not and let me know if not working. Then I'll try on your working theme which you will set as live.

     

    Thanks

     

    0
  • Ifra Saqlain
    Community Moderator

    Hi Tan Bing,

    Here is your second answer of your second question:

    Btw I find the "request-description" field is inside iframe as below. How can we assign a value by add coding in script.js

     

    Ans. The process is same you can assign the tags and content in the val() function.

     

    Output is:

     

    If any query let me know :)

    Thanks

     

     

     

    0
  • Mona

    Hello everyone!

    I've managed to hide the subject line and description with the code suggested in this article:

    var formId = $("#request_issue_type_select").val();

    if (formId === '12345') {
    $('.form-field.request_subject').hide(); // Hide subject
    $('.form-field.request_description').hide(); // Hide description
    $('#request_subject').val('test'); // autofill subject
    $('#request_description').val('test'); // autofill description
    }

    However the page doesn't always seem to load correctly. Sometimes the fields disappear, sometimes they do not and only disappear when you reload the page. I'm guessing the script is not being loaded correctly, but I have no idea why or how to fix it.

    I tried using document.addEventListener('DOMContentLoaded', function() {}) and
    $(document).ready(function() {}), as both of them have been suggested in the comments of this article. I get the same results for both. It's also the same across Chrome, Firefox and Microsoft Edge.

    Hope someone can help!

    0
  • Ifra Saqlain
    Community Moderator

    I tried your code and working fine for me, can you share the public URL of your HC and set your working theme as Live so I can see that theme and can figure out the bug.

     

     

     

     

    Default form: no subject and description box.

     

     

    Form one: with both boxes.

    0
  • Mona

    Hi Ifra, thanks for the speedy response!

    I've been continuing trying different things yesterday and I think I found the issue already. At least I wasn't able to reproduce the bug anymore.

    The jQuery version that was loaded in our document_head.hbs was 3.5.1, I changed it to the version recommended in one of the articles here (https://code.jquery.com/jquery-3.6.0.min.js) and the issue didn't happen since.

    Hope this might help anyone who comes across this issue as well!

    0
  • Kuldeep Patidar

    Hi Brandon Tidd Samuel Mosher, I hope you guys are doing well!!

    Currently, I'm working on integration between two different Zendesk instances and I would like to ask for your kind assistance in updating one of the primary API call.

    FYI: I am following the instructions that are listed in this article.

    However, while creating the very first API i.e. "Create secure ticket" in the standard instance, I get this error {"error":"Unprocessable Entity","message":"Server could not parse JSON"}.

    Below is what I sent in API request:

    {% case 1900000485187 %}
    {% when 1900000485187 %}
    {% assign group = 360020723832 %}

    {% else %}
    {% assign group = '' %}
    {% endcase %}
    {
    "ticket":
    {
    "subject": "Test Request",
    "group_id": {{group}},
    "comment": {
    "body": "This has been done"
    },
    "requester": "abc@domain.net",
    "tags": [
    "escalated_from_standard",
    "ticket_stub_required"
    ],
    "custom_fields": [{"id": 360047087692, "value": "abc@domain.net"}]
    }
    }

    But, when I used the above code after deleting the Liquid Markup, the API functioned successfully and created a ticket in Secure Instance.

    {
    "ticket":
    {
    "subject": "Test Request",
    "group_id": {{group}},
    "comment": {
    "body": "This has been done"
    },
    "requester": "abc@domain.net",
    "tags": [
    "escalated_from_standard",
    "ticket_stub_required"
    ],
    "custom_fields": [{"id": 360047087692, "value": "abc@domain.net"}]
    }
    }

    I'm pretty sure I have something wrong with syntax, but honestly I can't get it.

    Any information that you could share would be greatly appreciated.

    Kindest Regards,

    Kuldeep

    0
  • Brandon Tidd
    Community Moderator

    Kuldeep Patidar -

    I think the issue is that group cannot be blank in the JSON.  In this case a default group would need to be supplied.  You can confirm by going to settings > API > Target Failures and scrolling down for details.  Hope this helps!

    Brandon

    {% else %}
    {% assign group = '' %}
    {% endcase %}
    {
    "ticket":
    {
    "subject": "Test Request",
    "group_id": {{group}},
    0
  • Brandon Geick

    I need to hide an auto fill the Subject field in a public form.  

    I need to hide my Description field.  

    0
  • Christopher Kennedy

    Hey Brandon,

    The tip from this article covers accomplishing that goal. Is there a specific blocker that you're encountering?

    Thanks,

    0
  • Ifra Saqlain
    Community Moderator

    Hi @Brandon Geick, as @Christopher Kennedy said the article covers which you want (See my comment above in this thread) if you have something different please share here.

    Thanks

    0
  • Kuldeep Patidar

    Hi Brandon Tidd,

    Thank you for your invaluable advice, I went along and it worked pretty well for me.

    0

Please sign in to leave a comment.

Powered by Zendesk