Need to update the HR Profile

suuriyas
Tera Contributor

HI Community,

 

I have a requirement, in our instances we have HR profiles which is getting updated by the integration (zone).

In HR Profile we have field called employee class with two options E and EXT. now when the zone sends the employee class of the user as trainee , apprentice or global assignee then it needs to update as E.

 

How can we achieve this?

1 ACCEPTED SOLUTION

@suuriyas 

to use field map, you need to use field map script

like this

answer = (function transformEntry(source) {

    // Add your code here
    var zone = source.u_employee_class; // (u_employee_class is the field in source table)
    if (zone == "T" || zone == "A" || zone == "GA") {
        return "E"; // use only 1 equal to
    } else
        return 'EXT';

})(source);

AnkurBawiskar_0-1748254084139.png

 

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

View solution in original post

15 REPLIES 15

HI @Keshav72 ,

 

Thanks for the response, I tried but it did not worked

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

    var zone = source.zone;
if (zone == "T" || zone == "A" || zone == "GA") {
    target.employment_type = "E";
}
})(source, map, log, target);

suuriyas_1-1747812384362.png

 

 

@suuriyas 

what value is coming in the source zone field?

based on that add comparison check

Also are you setting the correct value for Employee type on HR profile

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

    var zone = source.u_zone; // give the correct source field name
    gs.info('zone value' + zone); // check what came in logs
    if (zone == "T" || zone == "A" || zone == "GA") {
        target.employment_type = "E"; // use correct target field and correct choice value if it's drop down
    }
	
})(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

HI @Ankur Bawiskar ,

 

Thanks for the response, I have written a script like this

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

    var zone = source.u_employee_class; (u_employee_class is the field in source table)
    gs.info('zone value' + zone);
if (zone == "T" || zone == "A" || zone == "GA") {
    target.employment_type == "E";
}
})(source, map, log, target);
 
And i also checked the logs it is getting the value i want example zone valueA, zone ValueGA, zone ValueT this is what i see in logs. but still in target table(HR profile table) the value E is not getting updated in employee class.
backend name:
suuriyas_0-1747818202765.png

 

can you please let me know what mistake i have done.

I have written a onbefore transform script 

mapping:

suuriyas_1-1747818320976.png

 

@suuriyas 

don't use field map if you are using transform script, update transform script with 1 equal

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

var zone = source.u_employee_class; // (u_employee_class is the field in source table)
gs.info('zone value' + zone);
if (zone == "T" || zone == "A" || zone == "GA") {
target.employment_type = "E"; // use only 1 equal to
}
})(source, map, log, target);

OR

use field map script and don't use transform script

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

@suuriyas 

Hope you are doing good.

Did my reply answer 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