Transform Script to populate Manager Name

Rick Mann
Tera Expert

We are using a CSV file to import user records into our Service-Now instance where we will have a field for Manager Name. However, out AD only contains the Manager's employee number, not the name. I am writing a Transform script that will pull the ManagerEmployeeNumber value from the current user record, then lookup that value in order to populate the Manager Name value. The script does not appear to do anything when I run the transform, but I am able to create a new button in the user record that will correctly populate an individual user record. I have also tried running the transform script using the "onBefore" and "onComplete" values. Any help is appreciated.

Here is the transform script that I have written so far, which does not work:
-----------------------------------------------------------------------------------------------
//This portion of script is from the "Transform Script" script

/**
* For variables go to: http://wiki.service-now.com/index.php?title=Import_Sets_portal
**/

var vFindManager = new GlideRecord("sys_user");
vFindManager.addQuery("employee_number", source.u_manager_number);
vFindManager.query();
if (vFindManager.next())
{
target.manager = vFindManager.sys_id;
}

------------------------------------------------------------------------------------------------



//This portion of script is from the "Lookup Manager" button (which does correctly populate the Manager Name)

------------------------------------------------------------------

//gs.addInfoMessage("Manager " + current.u_manager_number);

var vFindManager = new GlideRecord("sys_user");
vFindManager.addQuery("employee_number", current.u_manager_number);
vFindManager.query();
if (vFindManager.next())
{
//gs.addInfoMessage("Lookup number " + vFindManager.employee_number);

current.manager = vFindManager.sys_id;
var sysID = current.update();
}
{
gs.addInfoMessage("Manager not found");
}

5 REPLIES 5

mamason
Tera Contributor

I used your transform script as it was just changing the manager field name and it worked for me? I tried several times and each time it worked as expected. I am on June11 Patch 1 release.