Expand my Community achievements bar.

SOLVED

How to open new URL after form submission

Avatar

Level 2

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

 

1 Accepted Solution

Avatar

Correct answer by
Level 10

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

 

View solution in original post

3 Replies

Avatar

Correct answer by
Level 10

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

 

Avatar

Level 2

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.

Avatar

Level 2

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.