I want to create a Field map in the existing Transform map. Can I do that?

Vaishnavi35
Tera Guru

Hi,

I need to add another Field map. 

Source table is this table only. Target table is sys_user table. I know the Target Field. How do select/create the source field?

I see only two "Active" Transform Maps. 1 is only for Groups

2nd is this one,

find_real_file.png

Where I only see 1 field map. Here only "User Name" is there, But in everyday sync all the values of the fields that are in sys_user table appear in ServiceNow not sure how this is working.

I need to verify if a particular field value is being Updated or not?

This is for LDAP Sync into servicenow.

Thanks,

Vaishnavi

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Is this LDAP data source?

what all fields are you importing from LDAP?

if you wish to import extra then give that in attributes; then when data loads that source field will get created

then you can create field map for that

Below is the screenshot from Ldap form for the attributes you wish to bring

Add that extra one here

find_real_file.png

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

8 REPLIES 8

That is for adding User in the Group.

//add users to SN groups
addSNMembers();

function addSNMembers() {
	var debug = true;
	var groupCount = 0;
	
	var log = '#### user group association transform script - onBeofre ###';
	try {
		//var guid = source.u_objectguid.toString();
		var guid = source.u_samaccountname;
		var user = new GlideRecord('sys_user');
		user.addQuery('user_name', guid);
		user.query();
		log += '\n  looking for user with AD objectGUID: ' + guid;
		// CN=eCAB,CN=Users,DC=bas,DC=corp,DC=dom^
		if (user.next()) {
			log += '\n user found';
			//target.mobile_phone=source.u_useraccountcontrol;
			/*
			
			if (user.active == false) {
				log += '\nactivating user';
				user.active = true;
				user.locked_out = false;
				user.last_login_time = gs.nowDateTime();
				user.update();
			}*/
			if (source.u_memberof.nil()) {
				// if a user is not a member of any group, they are not itil
				// users or ServcieNow- users
				//(JDP) 11/17/2017 - We want all employees to show active if indeed AD has them active
				//(JDP) Apply to final if below.
//				user.active = false;
//				user.update();
				log += '\nuser is not a member of any groups';
				if (debug)
					gs.log(log);
				return;
			}
			var adGroups = source.u_memberof.toString().split('^');
			//log += '\n AD Groups: ' + source.u_memberof.toString();
			//log += '\n AJAY AD Groups: ' + adGroups;
			for ( var group in adGroups) {
				mixGroup = adGroups[group].split(',');
				//log += '\n AJAY mixGroup: ' + mixGroup;
				for ( var snGroup in mixGroup) {
					myGroup = mixGroup[snGroup].split('=');
					if (myGroup[0] == 'CN') {
						var sMyGroupName = myGroup[1];
						// if (sMyGroupName.toLowerCase().indexOf('vip') >
						// -1) {
						// user.vip = 'true';
						// user.update();
						// }
						log += '\n MyGroupName: ' + sMyGroupName;
						var objGR = new GlideRecord('sys_user_group');
						objGR.addQuery('name', sMyGroupName);
						objGR.addQuery('active', 'true');
						objGR.query();
						if (objGR.next()) {
							groupCount++;
							//log += '\n Adding user to group ' + objGR.name;
							var rec = new GlideRecord('sys_user_grmember');
							//rec.addQuery('sys_user.user_name',guid);
							//rec.addQuery('sys_user_group.name', sMyGroupName);
													
							rec.addQuery('user',user.sys_id);
							rec.addQuery('group', objGR.sys_id);
							rec.query();
							//log += '\n***** user and group  '+ guid +  ' '+ sMyGroupName + '****';
							if (rec.next()){
								log += '\n !!!!!!Group association already exists '+ objGR.name;
							}
							else {
							
							rec.initialize();
							rec.user = user.sys_id;
							rec.group = objGR.sys_id;
							rec.insert();
							//objGR.active = true;
							//objGR.update();
							
							user.update();							
								log += '\n Created '+ objGR.name;
							}
						}
					}
				}
			}
			log += '\ngroup count: ' + groupCount;
			
				 
			// not a member of any of the AD groups pulled in to servicenow
			if (groupCount == 0) {
				if (user.active) {
				//(JDP) 11/17/2017 - We want all employees to show active if indeed AD has them active
				//(JDP) Also apply to similar if above.
				//	user.active = false;
				//	user.update();
					
				}
			}
		} else {
			log += '\nuser NOT found';
			ignore = true;
		}

		if (debug) {
			gs.log(log);
		}
	} catch (ex) {
		gs.log('user group association transform onBefore exception: ' + ex);
		gs.log(log);
	}
}

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Is this LDAP data source?

what all fields are you importing from LDAP?

if you wish to import extra then give that in attributes; then when data loads that source field will get created

then you can create field map for that

Below is the screenshot from Ldap form for the attributes you wish to bring

Add that extra one here

find_real_file.png

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

This is where you are saying to add the attribute?

But these are not the "names" of ServiceNow field. I am assuming these are LDAP or MIM Names?

find_real_file.png

Thanks,

Vaishnavi

yes those are ldap attributes names.

if you add new value there and import; it should create field on staging table and then you can have your field map

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader