Open Outside URL on Form Submission

Is there any way to open a non-Retool URL on a form submission? I know the code is sandboxed so I cannot use JS.

Hey @DakotaB :wave: Are you using a Form component? If so – there's no native way to open a URL. But if you can use a Button component, there's an option to open an external webpage (+ the option to do it in a new tab). Would that work?

1 Like

@justin Thanks for confirming. I need to hit a webhook with the data and then redirect to another page, so not sure how I could get both actions to happen using a button.

Ah that’s an interesting one. How are you hitting the webhook, via a query?

Yes, just a standard REST query using Retool’s queries.

Is there any way to trigger a Retool button using JS?

I could have the button submit to my query, and then have that run another query that simulates a click on a hidden button.

Hi @DakotaB! You can use the utils.openUrl() function inside of a Run JS Code type query. If you run that on success of the form submission query you should be golden!

https://docs.retool.com/docs/scripting-retool#utilsopenurlurl-innewpage

1 Like

@alex-w and @justin Thank you both, that is exactly what I needed and thanks for the reference in the docs. I did search there first but did not find it.

On a side-note, can one you explain why JS is sandboxed for Retool? I'm asking out of curiosity because I don't know what that means/why that is the case. My reason for asking is so far, the JS being sandboxed has been the only thing limiting how far we can take Retool so far.

If JS wasn’t sandboxed, it would open up some security issues for an organization. I believe many of these are internal (anyone with editor access for any app can write JS), but I know that as a result we need to explicitly allow for any JS interactions that change values or connect to any systems that are outside of the open app.

1 Like