After Business Rule is getting Executed before my flow is creating Task and closes the RITM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hello,
This is my After update BR on SC Task Table
(function executeRule(current, previous /*null when async*/ ) {
if (current.request.state != '5') {
var ritmSysID = current.request_item.toString();
var grRitm = new GlideRecord('sc_req_item');
grRitm.query('sys_id', ritmSysID);
grRitm.query();
if (grRitm.next()) {
//Update RITM State
if (current.state == 2) { //Work in Progress
grRitm.state = 2;
grRitm.update();
} else if (current.state == 3 || current.state == 4) {
gs.sleep(10000);
if (grRitm.stage != 'waiting_for_approval') {
var sc_task = new GlideRecord('sc_task');
sc_task.addQuery('request_item', ritmSysID);
sc_task.addQuery('active', true);
sc_task.query();
if (!sc_task.next()) {
if (current.state == 3) { //Closed Complete
grRitm.state = 3;
} else if (current.state == 4) { //Closed Incomplete
grRitm.state = 4;
}
grRitm.update();
var reqSysID = grRitm.request.toString();
var grReq = new GlideRecord('sc_request');
grReq.query('sys_id', reqSysID);
grReq.query();
if (grReq.next()) {
if (grRitm.state == 3) { //Closed Complete
grReq.state = 3;
} else if (grRitm.state == 4) { //Closed Incomplete
grReq.state = 4;
}
grReq.update();
}
}
}
}
}
}
})(current, previous);
My flow is responsible for 2 Task and updating them for automating the state and stages we have created the above BR.
This works fine when i put a delay but as this is not recommended what can be done.
The issue is whenever my first task is gets closed this br runs before the flow creates the other task and RITM value is setting to close complete.
@Ankur Bawiskar any suggestions please?
