File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Server-Side Components/Business Rules/Auto-assign and notify owners of Affected CIs Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 1+ // Business Rule: After Update on change_request
2+ // Condition: affected_ci field has changed
3+ ( function executeRule ( current , previous /*null for insert*/ ) {
4+ // Suppose affected CI list is in a related list table change_request_ci
5+ var ciRel = new GlideRecord ( 'change_request_ci' ) ;
6+ ciRel . addQuery ( 'change_request' , current . sys_id ) ;
7+ ciRel . query ( ) ;
8+
9+ while ( ciRel . next ( ) ) {
10+ var ci = ciRel . cmdb_ci . getRefRecord ( ) ;
11+ if ( ci . owner ) {
12+ // create change_task (task table) record for owner
13+ var ct = new GlideRecord ( 'change_task' ) ;
14+ ct . initialize ( ) ;
15+ ct . change_request = current . sys_id ;
16+ ct . cmdb_ci = ci . sys_id ;
17+ ct . assigned_to = ci . owner ;
18+ ct . short_description = 'Review Change for your CI: ' + ci . name ;
19+ ct . insert ( ) ;
20+
21+ // send notification – could simply use gs.eventQueue or similar
22+ gs . eventQueue ( 'change.ci.owner.notification' , ct , ci . owner , current . sys_id ) ;
23+ }
24+ }
25+ } ) ( current , previous ) ;
You can’t perform that action at this time.
0 commit comments