Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Robust Transformer adding preceding space in output

EricG
Kilo Sage

Hi All:

 

I'm finally attempting to get my hands around converting my Transform Maps over to Robust import Set Transformers...

Geez....

 

I'm at the point (after a lot of trial and error) where my data is getting into the proper tables without duplication and 99.98% complete.  Now i have only 1 item remaining.

 

My Task:

Due to how my company has Azure AD installed/Azure AD limitations, I have 3 different domains where users need to have a user account created if they need access to specific domain applications.  Issue then is (example IT personel), my LDAP queries will pull "Duplicate" employee/user records.

E.G.  I work for Parent Company and have a Parent Domain user account.  I need to access a program in a subsidiary domain, so now i have a user account in domain SubA.   Likewise, other users may have upto 4 user accounts. 

 

Desired Solution:
I'm attempting to get a complete list of users from our HR system and only have 1 active account.  Beyond other data points, I'm getting HR's listed Manager and manager employee id.

 

Issue:

From my data feed, I'm able to place various fields and "Cleansed" fields into the appropriate tables and/or table fields.  The only thing I can't get done is placing the correct manager record into the employee's manager field (Which is a reference).

 

Current Output:

in my Robust Transformer, i'm mapping my Import set to a Staging table.
I have a Manager ID field and a manager sys_id field.

I'm using a Script Operation on the staging table to query the User table and return the sys it for the manager.

 

I'm getting the correct record sys_id returned, but the output is placing a space Infront of the sys_id.

I've tried using a trim() statement and .toString().   Neither works to remove the space.

Does anyone know why my output has the preceding space?

 

Here is my Script Operation.

 

 (function(batch, output) {
  // add your code here.
  for (var i = 0; i < batch.length; i++) {
  	var meMgr = "";
	var hrName = batch[i].input;
	

	var fndMgr = new GlideRecord('sys_user');
	fndMgr.addQuery("employee_number",hrName);
	fndMgr.query();

	while(fndMgr.next()){
		meMgr = fndMgr.sys_id;//email

	output[i] = meMgr.toString(); // return the value to be put into the target field
	gs.information('Eric - the output is '+output[i]);
  }
  
 }})(batch, output);

 

 

When i check the logs, there is no additional spaces (E.G. 2 spaces) between is and output[i].

1 ACCEPTED SOLUTION

EricG
Kilo Sage

OK, ended up contact HI Support for help and they weren't very clear on what exactly I needed to do.

 

When importing/updating the user table and updating a User field that is a Reference.
You need to make sure that the Transformer you are building has NONE selected in the Coercion action column of the ETL Entity fields.

I did this for both my Staging table and the User Table entity.  once done, adding manager.sys_id to the User.manager field worked like a charm

View solution in original post

1 REPLY 1

EricG
Kilo Sage

OK, ended up contact HI Support for help and they weren't very clear on what exactly I needed to do.

 

When importing/updating the user table and updating a User field that is a Reference.
You need to make sure that the Transformer you are building has NONE selected in the Coercion action column of the ETL Entity fields.

I did this for both my Staging table and the User Table entity.  once done, adding manager.sys_id to the User.manager field worked like a charm