Auto-populating fields in ticket forms with custom field input data

5 コメント

  • Brett Bowser
    Zendesk Community Team

    Hey R. Bello,

    While I can't assist with custom code on my end, I did want to share some documentation we have available that may help point you in the right direction:

    I'll also get this post added to our Community Roundup for August to help provide visibility to other users who may be able to offer up some guidance. 

    Cheers!

    0
  • Thomas Verschoren
    Community Moderator

    Hey,

    In short I think you should change $("request_custom_fields_1111111").val(); to $("#request_custom_fields_1111111").val();

    But this only takes the field value upon submit, which may throw errors if fields are required.

     

    Other solution: set the field upon dropdown change.

    I did this recently for a client of ours: When they select a dropdown, we set the subject field based on the choice.

    https://support.cozie.be/hc/nl/requests/new?ticket_form_id=360000011197

    Although the field is visible, the concept is the same. 

     

    In your case it would be something akin to:

    //FORM ACTIONS
    //Set form subject based on dropdown
    $(document).on("change", "#request_custom_fields_360000077818", function() {
    $("#request_subject").val(this.value)
    });
    0
  • R. Bello

    Zendesk Support provided a link to this post:

    https://support.zendesk.com/hc/en-us/community/posts/208167958-Hiding-attachment-system-fields-on-ticket-form

    and I was able to find the right code for it. It wasn't coded under $(document).ready(function(), it had to include a submit function, see below:

     

    $(document).submit(function() {

    var subjectstring1 = $("#request_custom_fields_1111111111").val();

    if (window.location.href == "https://subdomain.zendesk.com/hc/en-us/requests/new?ticket_form_id=222222222"){
    $('#request_subject').val("New Email" + " - " + subjectstring1);

     

    0
  • Daniel Renwick

    Can you remove subject and body/description for a single brand among several?

    0
  • Kay
    Community Moderator

    Hi Daniel,

    In the request form you could do that yes.
    Something like

    if (window.location.href.indexOf("BRAND URL HERE") > -1) {
    document.querySelector('.request_subject').style.display = "none";
    document.querySelector('.request_description').style.display = "none";

    document.querySelector('.request_description').style.display = "none";
    }

    1

サインインしてコメントを残してください。

Powered by Zendesk