- 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:54 AM
Yes but can you also mention how / where you are 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 07:05 AM
Yes I am in the service portal on the record making updates that will trigger this Business rule. I also set it to run last now but no difference. I totally lost on this.
I just add another message and switched to gs.setRedirect
gs.addInfoMessage(url);
// action.setRedirectURL(url);
gs.setRedirect(url);
gs.addInfoMessage(url + 'test');
first and last gs.addInfoMessage are shown
not sure what to think now

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-11-2020 07:07 AM
So what exactly are you doing on the Service Portal? Which widget, page, etc.. Please describe your situation a bit more so it's easier to understand what you are after.
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 07:17 AM
There is a form widget we are using but I am not familiar with this.
When I load the record its on the form widget I trust, pointing to the record tbl and sp view.
sample from url without instance details:
lpcx?id=form&table=some_data&sys_id=1df0367bdbbd9410c42772e9f4961912&view=sp

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-11-2020 07:06 AM
Hi Ellie,
As Mark suggested using it in UI Action is a better option. In case you still need to be part of Business Rule then can you try below.
var url = "http://www.w3schools.com";
gs.action.setRedirectURL(url);
If it works then you can use below just ensure the URL is correct.
var url = gs.getProperty('glide.servlet.uri') + 'lpcx?id=lf&table=some_data&filter=number' + current.sys_id + '&view=sp';
gs.action.setRedirectURL(url);
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