- 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-12-2020 05:05 AM
Hi Chirag, I changed the above to on submit to prevent a loop but it would work. This just confirmed that there is no reload from server and I will as the widget developer to take a look at this.
I will accept your answer as correct.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-22-2023 04:42 AM
Hi Chirag,
This solution is good but this will not work while we are using current.setAbortAction(true);. if you have any use case of this please let us know.
Ansh Mahajan
ServiceNow Dev
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-07-2024 05:37 AM
Hi @Chirag A ,
what do you mean by xyz in gs.setRedirect ('/xyz'), I have wrote a Business Rule that create a problem when incident state changes to On Hold and I want that after saving, the page redirecte to the new Problem Record created, could you help me please, below the script
Thank you
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