Redirect to URL specified in the list

Hi,
I am trying to redirect on Save/Close to a URL which is specified in a single line text field called RedirectURL2 in the list. But it isn't working. I have also tried it using a field defined as a url in the list, but that doesn't work either. This is my script. Can you help?

// Redirect after saving
fd.spSaved(function() {
var redirectUrl = fd.control('RedirectURL2').value;
if (redirectUrl) {
fd.source = redirectUrl;
}
});

// Redirect after closing
fd.spClosed(function() {
var redirectUrl = fd.control('RedirectURL2').value;
if (redirectUrl) {
fd.source = redirectUrl;
}
});

Hi @peter.harrison,

Try using result.RedirectURL like described on this page. This should work with any string value that is formatted like a URL. Let me know if this helps.

This is what I changed it to, but this doesn't work either.

fd.spSaved(function(result) {
result.RedirectUrl = fd.control('RedirectURL2').value;
});

// Redirect after closing
fd.spClosed(function(result) {
result.RedirectUrl = fd.control('RedirectURL2').value;
});

Hi @peter.harrison,

Are there any errors in the console? You'll need to enable "Preserve log" to check:

Most likely, the problem is caused by using control() instead of field() or by using the wrong field name.

Additionally, try removing fd.spClosed() from the code. This is unlikely to cause any issues, but redirecting in spSaved() is enough, so spClosed() is redundant.

Thanks @IliaLazarevskii
I think I need Closed for when the user closes without saving?

This is what the log says:

Hi @peter.harrison,

The errors seem unrelated. Could you send a screen recording of the issue along with the full console log to support@plumsail.com?