Auto-filling a custom field on a ticket form | Community
Skip to main content

Auto-filling a custom field on a ticket form

  • April 6, 2020
  • 4 replies
  • 0 views

Hello,

I'm trying to hide some fields on our support form and automatically pre-fill them with the desired values. I found an article that explains how to do this with system fields like Subject and Description, but I'm having trouble pre-filling a custom drop down field. I was able to hide the field with the following code:

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

But I can't figure out the proper syntax for pre-filling this field. I tried the following code but it is not working:

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

An you help me to figure out the correct syntax to pre-fill this field with one of the existing drop down values?

Thank you,
Doug Shaner

4 replies

Heather13
  • April 7, 2020

Hi @Doug Shaner,

I can't speak to coding it on the Guide side, but I wanted to drop a comment to see if auto-filling might work for you once it becomes a ticket. 

As an example:

Conditions:

  • Ticket... is... Created
  • Comment Text... Contains the following string... please cancel

Actions:

  • Set Custom Field [Area] to Cancellation

 

Would that work for you?

Sincerely,

Heather


  • Author
  • April 7, 2020

Thank you Heather,

 

I was actually able to get my code to work by trial and error.  :-)  So I'm all set.

 

Take care,

 

Doug


Heather13
  • April 8, 2020

@Doug Shaner

So glad to hear you got it working! We would be so encouraged if you would share it! 


  • Author
  • April 8, 2020

Here is the code that hides three system fields and one custom multi-select field and pre-fills them.  Note that the custom multi-select field has to have the "tag" specified in the value as opposed to the value the user sees.

 

// customize equipment request form
if(ticketForm == 360000607551) {

     // Hide category
     $(document).ready(function() {
            $(".request_custom_fields_360024163811").hide();
     });
     $('#request_custom_fields_360024163811').val('equipment_request'); // autofill category

     $('.form-field.request_subject').hide(); // Hide subject
     $('#request_subject').val('Equipment Request'); // autofill subject

     $('.form-field.request_description').hide(); // Hide description
     $('#request_description').val('See attached form for details'); // autofill description

     $('.form-field.request_type').hide(); // Hide type
     $('#request_type').val('task'); // autofill type
}

 

There is an oddity here to note....   When testing this I had the fields visible on the screen so I could verify that the pre-filling was working.  This worked well for the system fields, but when the custom field is not hidden, the code that pre-fills it causes it to display incorrectly in that the field shows partially on the screen and the pre-filled value does not show.  For days I thought it was not working and kept trying different things.  Then when I finally submitted the form and checked the ticket I found that the pre-fill was working even though the field on the screen didn't look right.  Since I'm hiding the field anyway this doesn't matter.