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