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 @Ankur Bawiskar ,

 

Thank you so much it worked.

I have removed the field mapping and added the onbefore transform script it worked but can you let me know how we can do with field mapping script

@suuriyas 

Please mark my response and close the thread.

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

@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

HI @Ankur Bawiskar ,

 

The script which you provided is working fine but suppose when the employee class from source field is empty then in hr profile table it is getting updated as ext but it should not happen it should not update anything for this how can we achieve this?

 

current script:

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);

 

@suuriyas 

so should it be set as None?

If yes then do 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 '';

})(source);

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