Change RITM state if any SC_TASKS are on hold
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 08:50 AM
I looked through a couple of posts here and came up with a BR to place the RITM to 'Pending' if an SC_TASK was placed 'On Hold' but I can't seem to get it to work. I tried in two different ways. Can anyone shed light here?
Example 1
Example 2
(function executeRule(current, previous /*null when async*/) {
gs.addInfoMessage("current.state "+current.state);
var gr = current.request_item.getRefRecord();
if(current.state == -7){
gr.state ="Pending";
}
else{
gr.state ="In Progress";
}
gr.update();
gs.addInfoMessage("the set state is "+gr.state);
})(current, previous);
.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 09:24 AM
Go with the script like example 2, but more like this - checking the State values in your environment vs OOTB that I have included:
(function executeRule(current, previous /*null when async*/) {
gs.addInfoMessage("current task state = " + current.state);
var gr = new GlideRecord('sc_req_item');
if (gr.get(current.request_item)) {
if (current.state == -5) { //Pending
gr.state = -5; //Pending
} else {
gr.state = 2; //In Progress
}
gr.update();
gs.addInfoMessage("the RITM set state is " + gr.state);
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 09:40 AM
@Brad Bowman that worked. I just realized however that I have some RITM's (not many) that have parallel tasks, if i place two tasks 'on hold' and then move one of them back out of 'on hold', i'm not sure how that is going to affect the RITM state here. Any suggestions?
Thanks again!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 10:01 AM - edited 12-19-2022 10:01 PM
Hi @Russell Abbott ,
Yes, latest update will execute Business Rule and the RITM State will be updated back to WIP.
Just one more way to implement your requirement is by Flow Designer. Have you tried that?
Flow Designer is very easy to build, with no code, to build complex flow.
Try once with Flow Designer:
Regards,
Reshma
**Please mark my answer correct or helpful based on the impact**
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 01:55 PM
Thank you for your input here. We have a very complex Flow that was designed by a vendor when we had our implementation phase. I actually find Flow Designer to be very difficult to read. Part of that is more than likely my lack of training in that module, i found the older Workflow Editor much easier to understand.
With your notes however, I will look into that further