Update sys_user field to true when source contains a specific OU

tlindof
Kilo Expert

I have an OU call consultant that we store consultant ad accounts in. I have also created a Consultant true/false field on the sys_user table. I am trying to mark the consultant field to true when the source field contains OU=Consultant. I have crated this business rule to make the change.

 

Before

        insert/update

 

var target = new GlideRecord("sys_user");

target.addQuery("consultant","CONTAINS","OU=Consultant");

target.query();

while (target.next()){

target.consultant = "true";

target.update();

}

 

Am I missing something?

1 ACCEPTED SOLUTION

I forgot to wrap it in a function.



checkConsultant();



function checkConsultant(){



if(current.u_consultant)  


return;  




if(!current.u_consultant)  


current.u_consultant = true;  


}




That error goes away. However I would *really* suggest taking care of this in the LDAP transform map if at all possible.


View solution in original post

5 REPLIES 5

This BR is only going to touch records that have been created or updated. If nothing is changing from the LDAP side, then they won't update. That's why this should be addressed on the ldap transform map. It will take care of existing and new records.