Creating pre-filled ticket forms

Return to top

118 Comments

  • Simon Blouner
    Community Moderator
    Hey team,
    This is a really neat feature and something I've been in need of on previous projects - so good job on this one!
    I have however only been able to get it working on a clean Copenhagen theme installation, and not in e.g. the heavily custom theme I'm working on at the moment, which is actually also based on the Copenhagen theme. I don't know if some of my other javascript is causing this, because I'm not getting any console errors or the like?

    Feel free to reach out if you would like some session to check it out :-)
    1
  • Kasper Sørensen
    Zendesk Product Manager

    Hi @...

    Thanks for raising this issue. The new feature is only available when your theme is using Templating API v2. Is your custom theme perhaps using Templating API v1?

    0
  • Simon Blouner
    Community Moderator

    Hey @...

    Thanks for the quick reply!

    I can confirm my theme is built on the API v2 - but for good measure, this should probably be added to this article as a heads-up :-)

    0
  • Kasper Sørensen
    Zendesk Product Manager

    Working on that :) 

    0
  • Nova Dawn
    Zendesk Documentation Team

    Thanks for raising this Simon Blouner, it's a good addition to the documentation.

    0
  • Matt Heroux

    Can we pass through text field or numeric values as well? or just the field types listed above?

    0
  • Kasper Sørensen
    Zendesk Product Manager

    @... absolutely! I think this article only wanted to specify the required format for field types where the format is non-trivial. For text and numbers, you just pass in the text or the number :-) Like:

    /hc/en-us/requests/new?tf_1234=Hello
    0
  • Bruce Sattler

    Hi Team,

    I love this feature! Question: will this also work with conditional fields which are not visible yet when the form is opened?

    Thanks!

    Bruce

    2
  • Kasper Sørensen
    Zendesk Product Manager

    Hi @...,

    Yes it also works with conditional fields, even if they're not shown initially.

    1
  • 小林正左子

    That's a great feature!
    I wonder if the parameter keys and values are retained when the ticket form is reloaded?

    0
  • Juraj Jarmek

    Hello Xiǎolín,

    As long as the URL string is kept, if the page is reloaded, the values will be kept.

    Hope that helps!

    1
  • Hussain Mithaiwala

    Hello!

    This feature is really good. 

    Firstly, can this be used if there is only 1 form? meaning I don't need to put in the ticket form ID.

    hc/en-us/requests/new?tf_1260812645989=

    I just want to get an idea on the dropdown values, it says to use option and value

    If I have a dropdown with 2 values
    VALUE = ABC, TAG = ABC_TEST

    VALUE = XYZ, TAG = XYZ_TEST

    What would the url be for such a case using the one I pasted above.

    Appreciate your help.

    Hussain

     

    0
  • Kasper Sørensen
    Zendesk Product Manager

    Hi @...,

    The parameter value in this case would be the option value's tag. If it's a multi-select field you can comma-separate those tags as well. So in your case it seems it would be:

    /hc/en-us/requests/new?tf_1260812645989=ABC_TEST,XYZ_TEST
    0
  • Hussain Mithaiwala

    Hi Kasper

    Thank you for your reply.

    I did try it the same way you have written, however didn't work.

    I will try it again and will update if successful.

    Regards

    Hussain

    0
  • Darren

    Hi,

    Do you need a rich text editor or can you just use for example word pad?

    I am not a developer but this seems easy enough to implement.


    Thank you!

    0
  • Juraj Jarmek

    Hello @...,

    Please note that Word Pad is indeed a rich text editor.

    You could also use Google Docs or Microsoft Word Online from your Microsoft account, if you have one.

    Hope that answers it!

    0
  • 小林正左子

    Hello.
    For example, if there is a submission error in a ticket form, does the re-displayed ticket form retain the value of the parameter before the error occurred?

    0
  • Kasper Sørensen
    Zendesk Product Manager

    If form submission fails, we try to retain the values at the time of submitting, not the pre-filled values in the URL. Because the user could have changed the pre-filled values.

    0
  • Braintree Admin

    @... I wrote some custom code for our help center literally the evening before seeing this article. While it was a waste of my own time (lol/sob) it may be helpful for you or anyone not using v2 of the help center.

    DISCLAIMER: I am more of a JavaScript/jQuery hobbyist than a developer, so use at your own risk. :)

    Adding the below snippet will allow you to pre-fill fields using links like this:

    https://example.zendesk.com/hc/en-us/requests/new?ticket_form_id=123&fields=request_custom_fields_456,tag1|request_custom_fields_789,tag2

    Just swap 123 for your form ID, 456 and 789 for your custom ticket field IDs you want filled out, and tag1 and tag2 for the tags associated with the options you want selected for those fields. This format should work for any number of fields you wish to add, whether it's one or 10.

    I wrote this specifically for drop-down custom fields, but you could likely adapt the script for other field types.

    Anyways, here's the script you'd want to add to your new_request_page.hbs template:

    <script>
    $(document).ready(function() {
    var url = window.location.href;
    if (url.includes('fields') == true) {
    var queryDict = {};
    location.search.substr(1).split("&").forEach(
    function(item) {
    queryDict[item.split("=")[0]] = item.split("=")[1]
    }
    )
    try {
    var fields = queryDict.fields.split("|");
    fields.forEach(function(field) {
    var thisField = field.split(",");
    document.getElementById(thisField[0]).value = thisField[1];
    })
    }
    catch {
    }
    }
    });
    </script>

    For those new to jQuery, you should also make sure your page is set up to utilize jQuery by adding something like this:

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    2
  • Matt Heroux

    Question about URL retention - if a user navigates around the HC before going back to the form, it looks like we lose the passthrough string - is this something you plan on addressing?

    0
  • Kasper Sørensen
    Zendesk Product Manager

    Hi @...

    This is intentional. Pre-filled values based on URL parameters are specifically only in effect when those URL parameters are set. That way you can have different links pointing at the same form, pre-filling it in different ways.

    0
  • Garrett Galindo

    Hello,

     

    I am trying to get this rolling and it seems like it's not possible if only one form is in use. My Help center only allows submissions at the following URL with no form ID.

    Do we need to upgrade our account in order to utilize such a simple feature?

     

    zendesk.com/hc/en-us/requests/new

    0
  • Yijun Wang

    Hello,

    When pre-filling the forms with user information in GET request params, is there any recommended practices?

    Is there risk in user information being leaked via parameters stored in server access logs? How does Zendesk handle server access logs in this case?

    Thanks!

    0
  • Kasper Sørensen
    Zendesk Product Manager

    Hi @...

    No upgrade is needed. You just modify your links. For example, here's a link to your form where it says Hello Garrett in the subject :-)

    0
  • Kasper Sørensen
    Zendesk Product Manager

    Hi @...

    I would not recommend filling in any PII (personally identifiable information) into any URL. Simply because it's easy to copy-paste that URL and accidentally have your users accidentally leak the information that way. Side-note also that my gut reaction would be that it is better for you to store such information in the user object instead of the ticket, but of course use cases differ here.

    As for our logs, please refer to our data deletion policy.

    0
  • Alejandro Colon

    @... Is there any way to include a new line? Specifically, in the description field. I tried the following with no success:

    ASCII Character Description URL-encoding
    NUL null character %00
    SOH start of header %01
    STX start of text %02
    ETX end of text %03
    EOT end of transmission %04
    ENQ enquiry %05
    ACK acknowledge %06
    BEL bell (ring) %07
    BS backspace %08
    HT horizontal tab %09
    LF line feed %0A
    VT vertical tab %0B
    FF form feed %0C
    CR carriage return %0D
    SO shift out %0E
    SI shift in %0F
    DLE data link escape %10
    DC1 device control 1 %11
    DC2 device control 2 %12
    DC3 device control 3 %13
    DC4 device control 4 %14
    NAK negative acknowledge %15
    SYN synchronize %16
    ETB end transmission block %17
    CAN cancel %18
    EM end of medium %19
    SUB substitute %1A
    ESC escape %1B
    FS file separator %1C
    GS group separator %1D
    RS record separator %1E
    US unit separator %1F
    0
  • Kasper Sørensen
    Zendesk Product Manager

    Hey Alejandro, yes so it depends on whether or not you use a rich text editor or a plain text editor for the description field. If you use rich text, you should provide the HTML <br> tag, so you could have a parameter like

    ?tf_subject=Hello<br>World
    1
  • Alejandro Colon

    @...

    Thank you so much. I didn't even think of that even though I came up with a convoluted way of building the HTML paragraphs in the link. That is so much easier and makes more sense. 

    I think this would be a great thing to add to the article as I believe many people would like the ability to add new lines to the pre-filled ticket forms.

    0
  • Dmitry Kozhanov

    Hi guys,

    Thank you for the great feature.
    But for some reason, it doesn't work for our case.

    https://support.informationmapping.com/hc/en-us/requests/new?tf_subject=test

    Could you help me?

    Thanks!

    0
  • Kasper Sørensen
    Zendesk Product Manager

    Hi @...

    If I disable javascript on your site, then it works. So I don't know what specifically, but it seems your theme customization is doing something here which clears the form or gets in the way of our logic populating the form.

    0

Please sign in to leave a comment.

Powered by Zendesk