The CreatorCon Call for Content is officially open! Get started here.

We need to redirect the URL to a different page through business rule.

Simran Gadodiya
Mega Sage

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);

 

Screenshot 2022-11-07 164010.png

11 REPLIES 11

AnubhavRitolia
Mega Sage

Hi @Simran Gadodiya 

 

Please try below code:

 

 

var tsk = new GlideRecord("asset_task");
tsk.initialize();
tsk.parent = current.sys_id;
tsk.requested_for = current.caller_id;
tsk.asset = current.u_new_machine_asset.asset;
tsk.insert();
action.setRedirectURL(tsk);
})(current, previous);

 

 

 

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023

Gunjan Kiratkar
Kilo Patron
Kilo Patron

Hi @Simran Gadodiya ,

Please check Ankur's response on below thread :-

https://www.servicenow.com/community/developer-forum/redirect-url-through-business-rule/m-p/1744877 

 

Regards,

Gunjan Kiratkar


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy