I have a Question Regarding Transform Script

sasharma815
Tera Contributor

Import Source: External data file contains employee records with name, email, department, employment type, and manager email. Conditions to Apply During Transformation: Set the user's department based on the incoming department name. If Emp_Type is "Contract", mark the user as inactive and assign the title "Contractor". If Emp_Type is "Permanent", mark the user as active and assign the title "Employee". Set the user's manager reference based on the manager's email (if present and exists in the system). in servicenow

 

 

 

Can anyone explain what's the exact requirement by "Set the user's manager reference based on the manager's email (if present and exists in the system). in servicenow"

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@sasharma815 

you need to set 3 fields on target sys_user table (Active, Title & Manager) based on the incoming Emp_Type value.

It's an easy requirement.

you can use onBefore transform script for this to handle Active and Title

Manager you can have via field map

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {

    // Add your code here
    if (source.u_emp_type == 'Contract') {
        target.active = false;
        target.title = 'Contractor';
    } else if (source.u_emp_type == 'Permanent') {
        target.active = true;
        target.title = 'Employee';
    }

})(source, map, log, target);

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

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

"Set the user's manager reference based on the manager's email (if present and exists in the system). in servicenow"

what does this requirement means exactly
 

@sasharma815 

it means map the manager incoming value and see if it matches with any manager user in sys_user

For that you can have normal field map

I hope you are aware on how to do that.

I believe I have answered your question.

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

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