Skip to content

Commit c8c0892

Browse files
authored
change state if RITM state changes (#1399)
1 parent 5c182c0 commit c8c0892

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Create before insert/update business rule
2+
business rule on sc_req_item table and give condition if state changes to 2 OR cat_item.sc.catalogs is "yourchoice" and run this script.
3+
4+
This business is to set state on sc_task table when state changes on sc_req_item based on condition.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
(function executeRule(current, previous /*null when async*/) {
2+
var OPEN_STATE = 1;
3+
var WORK_IN_PROGRESS_STATE = 2;
4+
5+
var gr = new GlideRecord("sc_task");
6+
gr.addQuery('request_item', current.sys_id);
7+
gr.addQuery('state', OPEN_STATE); // Only fetch tasks in Open state
8+
gr.query();
9+
10+
while (gr.next()) {
11+
gr.setValue('state', WORK_IN_PROGRESS_STATE); // Update the task to Work in Progress
12+
gr.update();
13+
gs.log('Task ' + gr.number + ' updated from Open to Work in Progress');
14+
}
15+
})(current, previous);

0 commit comments

Comments
 (0)