LDAP Users Import to Update/Clear fields

Luiz Lucena
Mega Sage

Hi all, 

We are using LDAP to import users from AD into ServiceNow for a year now. Everything was looking fine.

We just released some service catalog items that requires manager approval and the issues are showing up now regarding LDAP user importing.

We have 2 different classes of users: regular employee and contractors. 
The manager field for contractors was always in blank for AD users, as they are managed in another internal system.

So, when we started using ServiceNow last year, a custom attribute was created in AD users account to have the approvals being directed correctly in ServiceNow to those contractor manager's.

The problem is that when a contractor is converted into regular employee, LDAP fills the Manager field with the current manager's name but is not clearing the custom field Contractor Manager. The approvals are being sent to the wrong person.

find_real_file.png

See above, both fields not empty. 

Below is the script to map the custom AD attribute to the custom field in ServiceNow:

find_real_file.png

 

Is there anything that could be done to have LDAP update users information correctly?

Was thinking in add the ELSE below, but not sure if will work.

Any clue?

answer = (function transformEntry(source) {
	if(source.u_atccontractormanager){
		var getManager = new GlideRecord('sys_user');
		if(getManager.get('user_name',source.u_atccontractormanager)){
			return getManager.sys_id;
		}else{
                   source.u_atccontractormanager = '';
                 }
	}
	return "";

})(source);
11 REPLIES 11

You could just do something like this:

find_real_file.png

That condition would not make much sense, as someone may change as manager for another user OR the user may change position and sometimes changing manager as well.

Ah, you know what, you're right. You could set it to Manager is Empty. I just tested this and it works. Same BR setup as my image above, except change the 'changes' condition to ' is empty '.

Mike Patel
Tera Sage

try adding else condition to your script. it should work if you have cleared out u_atccontractormanager attribute in AD.

answer = (function transformEntry(source) {
	if(source.u_atccontractormanager){
		var getManager = new GlideRecord('sys_user');
		if(getManager.get('user_name',source.u_atccontractormanager)){
			return getManager.sys_id;
		}else{
                   return = '';
                 }
	}
	return "";

})(source);

Coleton
Kilo Guru

If I was able to answer your question correctly, please let me know by marking it as correct. Thank you!