Ricerche recenti


Nessuna ricerca recente

Redirect after submit request

Con risposta


Data ultimo post: 14 apr 2022

Hey there,
 
I' looking to redirect my logged in users to the home page instead of the ticket detail after submit a new request. I tried the following but didn't work out: 
 
try{ 
    window.location.href = "/home";
  } catch(e) {console.error(e);}
});
 
Any ideas ?
 
Thanks !

0

5

5 commenti

image avatar

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


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


image avatar

Greg Katechis

Zendesk Developer Advocacy

Yep, that's what the above code snippet will allow you to do!

1


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


image avatar

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


Accedi per aggiungere un commento.

Non hai trovato quello che cerchi?

Nuovo post