How to open new URL after form submission | Community
Skip to main content
jeanetter358457
Level 2
February 27, 2023
Solved

How to open new URL after form submission

  • February 27, 2023
  • 2 replies
  • 1060 views

I am working on AEM 6.5 and am trying to open a new URL after form/data submission.

I have tried:

xfa.resolveNode("subEnd.subEndPage.subEndText.btnSubmitButton").execEvent("click");
xfa.host.messageBox("Thank you for completing the survey");
xfa.host.gotoURL("https://newURL");  

Result:  Data submits but doesn't go to new url

 

xfa.resolveNode("subEnd.subEndPage.subEndText.btnSubmitButton").execEvent("click")
xfa.host.messageBox("Thank you for completing the survey");

app.launchURL("https://newURL", true)

Result:  Data does NOT submit but goes to URL in same tab (not a new one).

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by radzmar

It might be better to decouple methods that rely on the speed of external ressources or users. So instead of using one event to execute all of them use several. Put the part that happens after the submitting into the postSubmit event of the form or button and wrap the messageBox in an if-statement to make sure the following script is only executed after the modal was closed. 

 

if (xfa.host.messageBox("Thank you for completing the survey") > 0) { app.launchURL("https://newURL", true); }

 

2 replies

radzmar
radzmarAccepted solution
Level 10
February 27, 2023

It might be better to decouple methods that rely on the speed of external ressources or users. So instead of using one event to execute all of them use several. Put the part that happens after the submitting into the postSubmit event of the form or button and wrap the messageBox in an if-statement to make sure the following script is only executed after the modal was closed. 

 

if (xfa.host.messageBox("Thank you for completing the survey") > 0) { app.launchURL("https://newURL", true); }

 

jeanetter358457
Level 2
February 28, 2023

I attempted what you suggested and placed the opening of the new URL to the postSubmit event of the button and nothing happend.  The event did not fire.

jeanetter358457
Level 2
February 28, 2023

I had a window.print() that was causing the new window to not be opened properly,  I moved this to after the window.open() and now it opens the window as expected.