File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
Business Rules/RITM state change Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change
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.
Original file line number Diff line number Diff line change
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 ) ;
You can’t perform that action at this time.
0 commit comments