Automatically Populate Subject and Description Based on Drop-Down | Community
Skip to main content

Automatically Populate Subject and Description Based on Drop-Down

  • August 8, 2024
  • 3 replies
  • 0 views

I'm trying to autopopulate the subject line from a dropdown value that the requestor would select from the form. I currently have the code below that is successfully hiding the subject field but the custom dropdown value selected isn't populating into the subject line. Nothing is actually populating. Right now this code is theoretically inputting the custom value when the Submit button is clicked. Can someone help tell me what I'm missing in my code to get this to work? Thank you!

 

//Hide Subject and auto populate with custom field dropdown selection
$(document).ready(function () {
var ticketForm = location.search.split('ticket_form_id=')[1];
var subject_value = $('.request_custom_fields_987654321').val();
 if(ticketForm == 123456789) {
   $('#request_subject').parent('.request_subject').hide();
   $("#new_request").submit(function(e){
       $('#request_subject').val(subject_value);
   })
    }
})

3 replies

  • August 13, 2024

Hello @noelle 

Is your Help Center public and you could share a link to your submit form? I would like to have a look and make sure I provide a suitable code for your use case.


  • Author
  • August 14, 2024

Hi @jakub20 it's not a public help center unfortunately.  I can maybe put this on our other help center if that works? But it's not technically live yet. I'd like to not publicly provide our helpcenter, would you be okay providing your email? I can send you the link there :)


  • August 20, 2024

@noelle Where do you have this code inserted? With Copenhagen v3 I was able to add the following code at the bottom of the script.js folder. After Copenhagen updated to v4 this no longer works.

  })();
$('.form-field.string.optional.request_subject').hide();// Hide subject 
$('.form-field.string.required.request_subject').hide(); // Hide subject 
$('.form-field.request_description').hide(); // Hide description
$('.form-field label:contains("Attachments")').hide(); // Hide label for Attachments
$('#request_subject').val('Internal Request'); // Autofill subject 
$('#request_description').val('Please see details below.'); // Autofill description
$('#upload-dropzone').hide(); // Hide upload box for Attachments