File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
Server-Side Components/Background Scripts/User Email mismatch with Cmn Notif device Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ // Background Script - Run in Scripts > Background
2+
3+ function findEmailMismatches ( ) {
4+ var mismatches = [ ] ;
5+
6+ var deviceGR = new GlideRecord ( 'cmn_notif_device' ) ;
7+ deviceGR . addNotNullQuery ( 'email_address' ) ; // Only check devices with email populated
8+ deviceGR . addNotNullQuery ( "user" ) ; // Ensure device is linked to a user
9+ deviceGR . addQuery ( "type" , "Email" ) ; // Filter for email-type devices
10+ deviceGR . addQuery ( "name" , "Primary Email" ) ; // Filter for primary email devices
11+ deviceGR . addActiveQuery ( ) ; // Only active devices
12+ deviceGR . query ( ) ;
13+
14+ while ( deviceGR . next ( ) ) {
15+ var userGR = new GlideRecord ( 'sys_user' ) ;
16+ userGR . addQuery ( 'email' , deviceGR . email_address ) ;
17+ userGR . query ( ) ;
18+
19+ if ( ! userGR . next ( ) ) {
20+ // Found a mismatch
21+ mismatches . push ( {
22+ device_sys_id : deviceGR . getUniqueValue ( ) ,
23+ device_name : deviceGR . getDisplayValue ( ) ,
24+ email : deviceGR . email_address . toString ( ) ,
25+ user_sys_id : 'No matching user found'
26+ } ) ;
27+ }
28+ }
29+
30+ return mismatches ;
31+ }
32+
33+ // Execute and log results
34+ var results = findEmailMismatches ( ) ;
35+ gs . info ( 'Found ' + results . length + ' email mismatches:' ) ;
36+
37+ for ( var i = 0 ; i < results . length ; i ++ ) {
38+ gs . info ( 'Mismatch: Device=' + results [ i ] . device_name + ', Device Email=' + results [ i ] . email ) ;
39+ }
You can’t perform that action at this time.
0 commit comments