- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-11-2020 06:37 AM
Hi All,
I have a business rule that creates 1 or more of records in a related table so far so good.
I need to redirect to the record list in the related table when all records have been created and I cannot get the redirect to work at all.
This is for Service Portal but doesn't work in the backend either.
(function executeRule(current, previous /*null when async*/) {
var catPerData = current.somedata.toString();
var PerData = catPerData.split(',');
for (var i = 0; i < PerData.length; i++){
var gr = new GlideRecord ('some_data');
gr.initialize();
gr.number = current.sys_id;
gr.some_data = PerData[i];
gr.name = gr.some_data.name;
gr.insert();
}
var url = gs.getProperty('glide.servlet.uri') + 'lpcx?id=lf&table=some_data&filter=number' + current.sys_id + '&view=sp';
action.SetRedirectURL(url);
// gs.setRedirect(url);
})(current, previous);
Has anyone got any idea on what might be the issue?
Thanks!
Solved! Go to Solution.
- Labels:
-
Scoped App Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-11-2020 09:17 AM
Please mark my solution, if that works for you.
Chirag A
Servicenow Dev

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-11-2020 06:40 AM
Hi there,
Looks like a minor typo, use:
action.setRedirectURL(url);
Lowercase s.
Obviously, if url is valid š You could add some debugging to check url.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-11-2020 06:45 AM
Hi Mark,
Thanks I corrected this but its still not working.
When I click Save and the BR runs I can see that the records are added to the related list at the bottom of the form the related list link numbers increment but I stay on the form.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-11-2020 06:47 AM
So did you debug if the URL is valid? And where exactly are you using / testing this. Your first message says service portal though also business rule?
Just server side System UI, this should work fine.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-11-2020 06:53 AM
I did I also displayed the url in a message and copy/paste into new window and list is displayed
I also tried with test url var url = "http://www.w3schools.com"; and it does not redirect.
Hi Ellie,
Looks like this can be your solution.
Create a BR with below Code and a Client Script code as below. Both together works for me...
Client script UIType ALL, Type OnLoad