Redirect in business rule not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2023 09:51 AM
I have an onAfter business rule that runs on updates. Literally all I'm trying to do is have it redirect to the instance homepage. I've already logged the URL and confirmed that it's correct but it's not working. Here is my code:
(function executeRule(current, previous /*null when async*/) {
var baseUrl = gs.getProperty('glide.servlet.uri');
gs.setRedirect(baseUrl);
})(current, previous);
I have also tried using action.setRedirectUrl(baseUrl) and well as current.setRedirect(baseUrl). None of these work. Even if handling the redirect in a UI Action could work, I need this to be done in a business rule.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2023 09:54 AM
I'm guessing the problem is that it is onAfter...it doesn't trigger until after the crud operation at which time there is no redirect, the redirect/page load is done.
Test the theory with onBefore and see if that helps? If the rest of your BR needs to be onAfter, perhaps separate the tasks/steps into different BRs...?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2023 10:03 AM
I have tried making it onBefore as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2023 10:01 AM
Hi @MC1,
Have you tried the below one?
action.setRedirectURL(url);
Else take a look at old thread: Business rule action.SetRedirectURL(url); or gs.setRedirect(url); not working for me
If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers.
Thanks,
Sagar Pagar