We need to redirect the URL to a different page through business rule.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2022 03:13 AM
Hello,
We need to redirect the URL to a different page through business rule.
Once the condition is true Asset task should be open to new window.
When specific resolution code is selected and incident is resolved then we need to create asset task and redirect to the asset task.
we are using gs.setRedirect(url) or action.setRedirect(url).
This is the script that we are using
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var task = new GlideRecord("asset_task");
task.query();
task.parent = current.sys_id;
task.requested_for = current.caller_id;
task.asset = current.u_new_machine_asset.asset;
task.insert();
action.setRedirectURL(task);
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2022 03:28 AM
hello @Simran Gadodiya can you try this below script
var task = new GlideRecord("asset_task");
task.parent = current.sys_id;
task.requested_for = current.caller_id;
task.asset = current.u_new_machine_asset.asset;
task.insert();
action.setRedirectURL(task);
})(current, previous);
Hope this helps
Mark the answer correct if this helps you
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2022 03:51 AM - edited ‎11-07-2022 03:54 AM
Hi @Simran Gadodiya ,
action object is defines in UI Action, it won't work in BR. FOr redirection to work in BR, use gs.setRedirect
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var task = new GlideRecord("asset_task");
task.query();
task.parent = current.sys_id;
task.requested_for = current.caller_id;
task.asset = current.u_new_machine_asset.asset;
task.insert();
gs.setRedirect(task.getLink)
})(current, previous);
I hope this help.
Please mark this helpful if this helps and Accept the solution if this solves your issue.
Regards,
Kamlesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2022 06:17 AM
Hello,
Thanks for your solution, We have printed redirect URL in log that we are getting is correct but it is not redirecting to the required page .
Thank You!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2022 06:22 AM
Did you try gs.setRedirect() function as I mentioned in my previous post? It should work. action.setRedirect will not work as action object is not define in BR