Recent searches


No recent searches

Automatically Populate Subject and Description Based on Drop-Down



Posted Aug 08, 2024

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);
   })
    }
})


0

3

3 comments

image avatar

Jakub

Zendesk Customer Care

Hello Noelle Cheng 

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.

0


Hi Jakub 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 :)

0


Noelle Cheng 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

0


Please sign in to leave a comment.

Didn't find what you're looking for?

New post