File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
Business Rules/Add notes for tag addition or removal Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ /**********************BR COnfig Start***************************/
2+ /*
3+ When: before
4+ order: 100
5+ delete: true
6+ Filter: labelISNOTEMPTY^label.nameISNOTEMPTY^EQ
7+ */
8+ /**********************BR COnfig End***************************/
9+ ( function executeRule ( current , previous /*null when async*/ ) {
10+ // Check if logging for tag removals is enabled
11+ if ( gs . getProperty ( 'custom.tag_entries.log_removal' ) . toString ( ) == "true" ) {
12+ var current_table = current . getValue ( 'table' ) ; // Retrieve the name of the current table
13+ var allowed_tables = gs . getProperty ( 'custom.tag_entries.tables' ) ; // Get the list of allowed tables from properties
14+ allowed_tables = allowed_tables . split ( ',' ) ; // Split the string into an array
15+
16+ // Verify if the current table is in the allowed list
17+ if ( allowed_tables . indexOf ( current_table ) > - 1 ) {
18+ var gr_task = new GlideRecord ( current_table ) ; // Create a GlideRecord object for the current table
19+ try {
20+ // Query the record using sys_id stored in table_key
21+ gr_task . addQuery ( "sys_id" , current . table_key . getValue ( ) ) ;
22+ gr_task . query ( ) ; // Execute the query
23+
24+ // If the record is found, update work_notes if the field is valid
25+ if ( gr_task . next ( ) ) {
26+ if ( gr_task . isValidField ( 'work_notes' ) ) {
27+ gr_task . work_notes = "Tag removed: " + current . getDisplayValue ( 'label' ) ; // Append removal info to work notes
28+ gr_task . update ( ) ; // Save the changes made to work notes
29+ }
30+ }
31+ } catch ( e ) {
32+ // Log any exceptions encountered during execution
33+ gs . log ( "Exception occurred in the business rule Updating record when tagged" + e . message ) ;
34+ }
35+ }
36+ }
37+ } ) ( current , previous ) ;
You can’t perform that action at this time.
0 commit comments