Automatically Populate Subject and Description Based on Drop-Down

24 Comments

  • David Edgson
    Comment actions Permalink

    I don't know if you ever got your answer for this, but this is something we did.

    We hide the Subject field, and code similar to the following to set the Subject value when the user hit's submit on the request. Instead of the static value you see below, we actually populate the subject value variable by combining the values of several custom fields the user fills out on the form.

    var subject_value = "Insert Subject Value Here";

    $("#new_request").submit(function(e){

    $('#request_subject').val(subject_value);

    });

     

    2
  • Dan Cooper
    Comment actions Permalink

    Here is the example of what we do based on the Ticket Form drop down.  If a specific form is selected this runs from the JS tab. 

      var ticketForm = location.search.split('ticket_form_id=')[1];

      if(ticketForm == 172283) {

          $('#request_subject').val('Attendance Line Event');

          $('#request_description').val('Updating Attendance Line...');

          $('#request_subject').parent('.request_subject').hide();

          $('#request_description').parent('.request_description').hide();

      }

    1
  • Martin Sachs
    Comment actions Permalink

    I'm interested in this as well.  Would love to hear if it worked before I give it a stab.  

    @Daniel - I'm trying to take this one step further and trigger the answer suggestions.  I can get the form to render with the subject like in your example but answer suggestions don't trigger unless I take manual action in the subject field.

    What I'm trying to do is marry this whole process together.  I have a custom field with nested values that helps inform us of the issue - I want to populate the subject based on that field and then have suggested articles show up to help deflect the submission.

    Any guidance on how to trigger the suggestions programmatically?

    1
  • David Edgson
    Comment actions Permalink

    That's what we do in our zendesk. we hide the subject field and populate it at the point of submitting with values the user entered into other fields. This example creates a subject like "New User John Doe 2019-01-01"

    So in addition to hiding the fields like Dan does, we add this code that sets the subject field upon submitting the ticket.

    $("#new_request").submit(function(e){

    //33860927 = FirstName
    //33855548 = LastName
    //33855528 = FirstDayOfWork

    var subject_value = "New User " + $("#request_custom_fields_33860927").val() + " " + $("#request_custom_fields_33855548").val() + " " + $("#request_custom_fields_33855528").val();


    $('#request_subject').val(subject_value);


    });

    1
  • Brett - Community Manager
    Comment actions Permalink

    Hey R. Bello,

    I replied to your post here and added your question to our community roundup for August: Auto-populating fields in ticket forms with custom field input data

    I also see you created a ticket for our Customer Advocacy team to look at. Someone from the appropriate team will reach out to you regarding your question :)

    Cheers!

    1
  • Jessie Schutz
    Comment actions Permalink

    Hey Matthew! We've got a couple Moderators who are good with JS...I'll see if they're available to hop in here for you!

    0
  • Dan Cooper
    Comment actions Permalink

    Hi Matthew, 

    I found an example that might be able to help you get your drop-down working to update your subject and description.  I use a similar setup for hiding and pre-filling the subject and description on my forms based on the form that has been selected.  I haven't done the same for a custom drop down, but this example might be able to help you on your path to accomplish this. 

    Example via Stack Overflow

    0
  • Jessie Schutz
    Comment actions Permalink

    Hey Matthew!

    Did this answer your question?

    0
  • Dan Cooper
    Comment actions Permalink

    Hi Martin, 

    I wish I had an answer here, but my solution was also diving into a new skill set for me.  I haven't had to dig that far just yet.  I would probably start by digging into the default Javascript in the theme to see if there is something controlling when the suggested articles present and work from there.  I'm hoping someone else that knows a bit more about this can answer your question.  I'd love to know this myself.  

    0
  • Juliano
    Comment actions Permalink

    Hey Martin, this is exactly what I need too.

    Did you have any luck with this?

    0
  • Lila Kingsley
    Comment actions Permalink

    Hi,

    My need on the new request form is to have the custom field drop down value chosen by the user populate the subject (so we can hide the the subject on the form).

    I'm able to hide the subject using the "// Hide subject" code in the help center script.js as referenced in the Answer section of this article:  https://support.zendesk.com/hc/en-us/articles/115002860148-Disabling-the-subject-and-description-fields-on-the-new-request-form-in-Help-Center- 

    The article shows how to populate subject with a text string and it works fine, but, I'm not able to find anything in ZD support on using another field value (specifically a drop down) to populate subject. Though I see several references to it on the web which make it look possible...but I can't get them to work

    Can anyone advise how to accomplish populating the subject with the value selected in the custom drop down field?

     

    0
  • Jacob J Christensen
    Comment actions Permalink

    Hi Lila,

    You should be able to update a system field, like the subject field, with the input from a custom field, using a trigger notifying a target with the custom field's placeholder value

    Note: this is not recommended by Zendesk (although I do have something similar working reliably).

    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. 

    For the URL target the settings should be the following:

    Title

    Update subject field

    Url

    https://your-domain.zendesk.com/api/v2/tickets/{{ticket.id}}.json

    Method

    Put

    Attribute name

    ticket[subject]

    Basic Authentication
    Use your admin credentials to authenticate the target.

    Hope that helps you out! Let me know if you need more details.

    0
  • Lila Kingsley
    Comment actions Permalink

    Thanks Jacob!  Not sure this will work for me, as our need is to populate the subject field with the selected custom field drop down value BEFORE the HC "new request" ticket form is submitted (subject is required at submit in the form by ZD and that cannot be changed).  Since your solution uses a trigger, I believe it requires the ticket to exist. 

    Do you have experience using your solution in this scenario (populating subject field behind the scenes/hiding from customer before the HC ticket is submitted)?

    0
  • Jacob J Christensen
    Comment actions Permalink

    Hi again Lila,

    A trigger can perform action events upon ticket creation as well as updates, no problem there.

    We use almost the same thing for tickets requested through the Web widget - overwrite the original subject text with one from another field, and it works for us. As long as you have a placeholder available for the field input you'd like to use as the new subject text, it should work just fine for you as well.

    0
  • Jessie Schutz
    Comment actions Permalink

    Thanks for sharing your solution, David!

    0
  • William Grote
    Comment actions Permalink

    Hi Dan

    To hide and then autofill the subject with the name of the form, do you have to copy and paste that code you shared with the form ID for each form, or is there a way to do it so the name of any form picked from the initial form DD will get auto-filled to the subject line, that is the solution I am seeking

     

    thanks

    William

    0
  • William Grote
    Comment actions Permalink

    Scratch that, I just need to hide the subject field and then auto fill it when its submitted with the value from a custom drop down field (in this case, the drop downs lists the common support topics for this specific form - for this form there are 8 'topics'  which are in essence, the subject anyway

     

    So without having to add the specific code snippet for each possible variation, is there a way to grab the value and have it populate automatically, based on the value that the end user picks from the drop down?

    0
  • William Grote
    Comment actions Permalink

    Hi David,

     

    thanks for the input, im just learning this trial and error, I have never coded a thing before so this is like learning German in an afternoon 

     

    I came across another post that changes the description value rather than hiding it, but it doesnt work when I tried to use the same code for the subject  I entered this using the field ID from my custom drop down where the bold text is 

     

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

    it did not work, 

     

    All I want to do is the following, - if someone could help me with the code exactly as I need to past it into the JS Tab

     

    If a certain form is picked ( I have custom forms for each version of our product requiring support)

    Then hide the subject from the form, and upon submission, use the value from the  custom drop down on that form to fill in the value for the subject so that the agent sees it

     

    David, having used ZD for a while, your code to make the subject immediately fill with the new requester info is fantastic from an agent perspective, Kudos!

     

     

     

    0
  • William Grote
    Comment actions Permalink

    When the subject field is auto-filled, the answer bot not longer suggests articles based on key words, has anyone found a solution to this or a way to have the answer bot suggest articles based on the description rather than the subject? 

    0
  • Brett - Community Manager
    Comment actions Permalink

    Hi William,

    Answer-bot should look at both the Subject and Description of the ticket as mentioned in the following article: What part of a ticket does Answer Bot use to determine which articles to suggest?

    If you're using custom code that may be affecting the results of answer-bot. I won't be able to assist myself but it may be helpful if you provide the code you're using so other members can take a look for you.

    Thanks!

    0
  • R. Bello
    Comment actions Permalink

     We hide the Subject and Description and we're able to assign static values for them but we're trying something similar to what David has where the subject field is set upon the ticket submitted and populate the fields with actual data being submitted in the form. Here is the code we are using:

    var ticketForm = location.search.split('ticket_form_id=')[1];

    var subject_value = "New Email Request for " + $("request_custom_fields_1111111").val();

    if(ticketForm == 2222222) {

    $('#request_subject').val(subject_value);

    $('#request_description').val(subject_value);

    $('#request_subject').parent('.request_subject').hide();

    $('#request_description').parent('.request_description').hide();

    };


    When I submit the form with that code, the subject and description just say "New Email Request for " and does not include the custom field data which is part of the form being submitted. I've tried different variations from what I've seen online to include single quotes, input# and even brackets and sometimes I get "New Email Request for undefined" or "New Email Request for [object Object]".

    Any help in solving this is greatly appreciated. Thank you.

    0
  • Danny Koss
    Comment actions Permalink

    I've had success in auto-setting the subject based on the selected field using code similar to:

    $("#new_request").submit(function(e){
    var subject_value = $("#request_custom_fields_xxxxxxx").val();
    $('#request_subject').val(subject_value);
    });

    When the ticket comes into Zendesk Support, the subject of the ticket is the tag of the custom field. Is there a way to have the subject set to the user-facing value of the field as opposed to the tag?

    0
  • Brett - Community Manager
    Comment actions Permalink

    Hey Danny,

    I'm rather limited in the custom code field but it may be worth taking a look at the available placeholders for custom fields here: Using placeholders

    Hopefully, other users can jump in and offer up some advice on how to get the ticket value displaying instead of the tags.

    0
  • Danny Koss
    Comment actions Permalink

    Thanks, Brett.  In reviewing this documentation, it looks like there is a "name" object which maps to the title of the selected field.
    https://developer.zendesk.com/rest_api/docs/support/ticket_fields#updating-drop-down-field-options

     

    I haven't had any luck yet in getting the subject to be set as the name/title as opposed to the field tag.

    0

Please sign in to leave a comment.

Powered by Zendesk