Automatically Populate Subject and Description Based on Drop-Down

13 Comments

  • Jessie Schutz

    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
  • Daniel Cooper

    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
  • Daniel Cooper

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

      }

    0
  • Jessie Schutz

    Hey Matthew!

    Did this answer your question?

    0
  • Martin Sachs

    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
  • Daniel Cooper

    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

    Hey Martin, this is exactly what I need too.

    Did you have any luck with this?

    0
  • Lila Kingsley

    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

    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

    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

    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
  • David Edgson

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

    });

     

    0
  • Jessie Schutz

    Thanks for sharing your solution, David!

    0

Please sign in to leave a comment.

Powered by Zendesk