Function to find user titles in sys_user table that do not exist in another table

ABouland
Kilo Guru

Our firm is getting ready to roll out a large number of new user titles in Active Directory, where our SN user data comes from.  I want to be able to easily find user records that have a title that is not on the published list of acceptable titles (around 300 unique titles).  I've created a new table: Title List (u_title_list) with a single field 'u_title'  and I have imported all of the acceptable titles to this table.

I've managed to create script includes to do similar sorts of things to find users with duplicate employee numbers and then referenced the script include in a report but in trying to construct something similar here, don't seem to be getting there. 


Currently just attempting to do this in a background script to see if I am returning anything.

Current script:

function checkTitle() {
var grUSER = new GlideRecord('sys_user'); 
var grTITLE = new GlideRecord('u_title_list');

grTITLE.query();

while(grTITLE.next()){    

      // grUSER.initialize();
       grUSER.addQuery('title', grTITLE.u_title);   

       grUSER.query();

      if(!grUSER.next()){
                       gs.print("Did not Find: " + grUSER.title);
}          
}
}

Not getting any results though.  Have tried a few variations of the above but no results with any of them.

Script include was simply the method I've used to do something similar before but am fine with any efficient method to get a list of outliers.  Any suggestions are much appreciated.

 

Thanks,

Andrew