Redirect after submit request

Answered

5 Comments

  • Greg Katechis
    Zendesk Developer Advocacy

    Hi Carlos! I threw something together for this which should work for you. I didn't test this for many scenarios, so use this as an example and test it out to see if it works for you! You'll want to place this in your document_head.hbs:

    <script>
    let ticketNumber = window.location.href.split('requests/').pop();
    let ref = document.referrer

    if (ref.match('https://yoursubdomain.zendesk.com/hc/yourlocale/requests/new') && ticketNumber.match(/^[0-9.]+$/)) {

    window.location.href = 'https://yoursubdomain.zendesk.com/hc';

    }
    </script>
    It's not pretty at all, but it should get the job done. This will run whenever the url slug contains only a number, so it won't get caught by the ticket form id search value. Also, remember to replace "yoursubdomain" with your actual subdomain. If you use host-mapping, update the above snippet accordingly.
     
    If you run into any issues with this, let me know!
    1
  • Carlos

    Hi Greg ! thanks for the information. However, I'm not trying to not enter the new request page, instead I'm trying to redirect after the user submits a new request. So they should be able to fill the form and send it but immediately redirected to the home page. Does this make sense?

     

    Thanks ! 

    0
  • Greg Katechis
    Zendesk Developer Advocacy
    Yep, that's what the above code snippet will allow you to do!
    1
  • Matt Taylor

    Hi Greg Katechis

    Would you be able to provide the whole script with the formatting to allow it be to added to the standard hbs file?

    0
  • Greg Katechis
    Zendesk Developer Advocacy

    Hi Matthew! I just updated my post to include the script tag...forgot to do that before. You should be all set to go now!

    1

Please sign in to leave a comment.

Powered by Zendesk