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

Comments

16 comments

  • Avatar
    Gabriel Scott

    Can you hide the subject/description for only one form, if you have multiples?

  • Avatar
    Dipesh Dave

    Hey Gabriel,

    Unfortunately when you hide the subject/description for one form, it will hide the subject/description for all forms.

    - However as a workaround you could include custom ticket fields on these forms and name them separately from the system fields, so that way you can hide the subject/description field (which is a system field), but you can still display individual custom fields that you have added to the form.

    - For example you could name the custom field "Details of Issue" or "Topic" for the subject.

    Please feel free to reach out to us at Support@Zendesk.com in case you have further questions for the mentioned workaround!

  • Avatar
    Daniel Cooper

     

    If you wrap the code about in an If statement you can do this. 

    If(ticketForm == 123456) {

    Add code here

    }

    Replace 123456 with the ticket form ID which can be found at the end of the URL on the ticket form edit screen.  

  • Avatar
    LodiseSam (Edited )

    Do I need quotes around the ticketForm variable?  Without quotes, the if statement breaks all of my forms completely.  As in no fields at all.

    Second, the code works without the if statement, but does nothing with the if statement.  Can you take a look below and see if I am doing something wrong?  Maybe its not the exact correct variable id.  The url has "ticket_form_id=215063".  But i tried that too and same result.

    Code I am using:

    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
    }

     

    Edit: In case any one else runs into this. The changes just weren't showing up in the preview.  Once i published it, it worked perfectly.  Code i went with is below:

    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
    }

     

  • Avatar
    Jessie - Community Manager

    Thanks for coming back to share your solution, Sam!

  • Avatar
    Keith McKeon

    This works for me but is there a way to add the text from a custom text field (which i'm replacing the system description fields with)  into the ticket description?    I'm guessing you could insert the field ID of the custom field where indicated bold below but not sure how to format it.

    $('#request_description').val(the value from a custom field '); // autofill description

    I'd also like to set the subject based on another custom field.

     

    Thanks!

     

     

  • Avatar
    Jessie - Community Manager

    Hey Keith!

    To the best of my knowledge it's not possible to move text from a field to the description in a ticket...can you give me your use case on this? We might be able to come up with something else. 

  • Avatar
    Terry Waldron

    Hey folks,

     

    I have the same requirement as Keith , so at the moment using the code above all tickets that are being submitted through that form have the Description "test description" , I know I can change the text to anything i want but what I really need is for the ticket to state the alternative description field I have created.

     

    Any ideas? 

  • Avatar
    Jacob J Christensen (Edited )

    Hi Keith and Terry,

    You should be able to update a system field with the input from a custom field, using a trigger notifying a target with the custom field's placeholder.
    This is not recommended by Zendesk (although I do have something similar working reliably), and I'm unsure if the trigger can update the description or will simply create a comment to the ticket.

    There's a pretty good guide for doing something like this here, although it is for different fields - it should give you an idea of what's involved. 

    Hope that helps you out.

  • Avatar
    Chris Boyd

    Hi,

    I'm trying to hide a custom field using this method but not having much success.

    $(document).ready(function() {
    $('.form-field.string.optional.request_custom_fields_360000410968').hide();// Hide Custom Field
     
    is there more code than this needed, or is there something obvious that I've done wrong?
     
     
  • Avatar
    Socorro Fernandez

    Hey Chris!

    Your code looks good but I believe you can accomplish what you need with just identifying the element within quotes. Give this a try:

    $(document).ready(function() {

    $(".request_custom_fields_360000410968").hide();

    });

  • Avatar
    Socorro Fernandez (Edited )

    Hi Keith and Terry,

    I took a crack at this and I believe I have gotten it to work right for custom open text and dropdown fields. Please note, I am in the early stages of understanding and playing with js so take what you will of my answer :)

    I am considering that your new field will have some sort of input from an agent or customer at your help center so I put this under .change function so it will update the description field in real time as that new field gets updated. This will require us to create a variable to grab the .html or value so it can be inputted into the description field.

     

    Text of Open text custom field to Description example:

    $("#request_custom_fields_yournewfieldnumberhere").change(function() {
    var newdescription = $("#request_custom_fields_yournewfieldnumberhere").val(); 
    $('#request_description').val(newdescription);
    });

    Text of Drop down custom field to Description example:

    $("#request_custom_fields_yournewfieldnumberhere").change(function() {
    var newdescription = $(".request_custom_fields_yournewfieldnumberhere a").html();
    $('#request_description').val(newdescription);
    });

     

    Be sure to add your appropriate custom field number to where it says yournewfieldnumberhere

    You can also name your variable (var) to anything just be sure it matches. for example if I named my var altdesc I would want to make sure altdesc was added in $('#request_description').val(altdesc); part of the code

    Thanks!

    Edit: removed extra } from dropdown example

  • Avatar
    Chris Boyd

    @Socorro Perfect, thanks!

  • Avatar
    Terry Waldron

    Cheers Socorro , 

     

    Works perfect , thanks a lot

  • Avatar
    고혜경

    Hi Socorro, 

     

    I'd like to add multiple custom fields' value into subject. 

    How can I do ? 

     

    Thanks in advance ! 

  • Avatar
    Socorro Fernandez (Edited )

    Hi 고혜경,

    For this script example, I am going to use 2 open text fields and identify them both in the .change function so that any time either field value is updated, it is going to run the script and add the values of both fields to the subject field. We will want to create variables for each and then use + to put them together:

     

     $("#request_custom_fields_youropentextfieldone, #request_custom_fields_youropentextfieldtwo").change(function() {
    var fieldone = $("#request_custom_fields_youropentextfieldone").val();
    var fieldtwo = $("#request_custom_fields_youropentextfieldtwo").val();
    $('#request_subject').val(fieldone + fieldtwo);
    });

     

    Be sure to add your open text custom field number to where it says youropentextfieldone and youropentextfieldtwo

    If you want to add a space between the field values you will need to add the code for it. There may be another way to do this but I did it by adding " "  in between fieldone and fieldtwo in the script which would look like this:

      $('#request_subject').val(fieldone + " " + fieldtwo);

    if you add the space code, there is always going to be space even if only one field has a value added to it. For Example if only fieldtwo is updated with a value, you can expect one space and then the value of fieldtwo to be added in the subject field. If both fields are required on your form than it shouldn't be an issue :)

    Also, glad to hear the other scripts are working for others! 

    Thanks

    Edit: put code in code format 

     

Please sign in to leave a comment.

Powered by Zendesk