File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 1+ //Business Rule: After update on the incident table
2+ //Condition: Additional comments changes
3+ //Create on global Tag record ex: Comments added
4+
5+ ( function executeRule ( current , previous /*null when async*/ ) {
6+
7+ var caller = current . caller_id . user_name ;
8+ // Add tag to the incident record if the comments is updated by the caller
9+ if ( current . sys_updated_by == caller ) {
10+ var add_tag_entry = new GlideRecord ( 'label_entry' ) ;
11+ add_tag_entry . initialize ( ) ;
12+ add_tag_entry . label = '<sys_id of the Tag>' ;
13+ add_tag_entry . table = 'incident' ;
14+ add_tag_entry . table_key = current . sys_id ;
15+ add_tag_entry . insert ( ) ;
16+ } else {
17+ // Remove tag from the incident record if the agent responds back to the caller
18+ var remove_tag_entry = new GlideRecord ( 'label_entry' ) ;
19+ remove_tag_entry . addEncodedQuery ( "label=<sys_id of the Tag>^table_key=" + current . sys_id ) ;
20+ remove_tag_entry . query ( ) ;
21+ if ( remove_tag_entry . next ( ) ) {
22+ remove_tag_entry . deleteRecord ( ) ;
23+ }
24+ }
25+
26+ } ) ( current , previous ) ;
You can’t perform that action at this time.
0 commit comments