How to upload multiple skills into ServiceNow employee profile table

Siva vittanala
Tera Contributor

Hi team, I wanted to load data into servicenow Employee profile table from Excel sheet using import set and transform map process.

But in Excel user skill column contains multiple skills, but in the system it will table one record each time. how to split the data having multiple skills and load into service now tables.

 


I have Excel sheet and ServiceNow profile table

IDNameManagerUser RoleUser Skill

 123456    Testuser                                                      testmanager                     developer                                     java,.net

 

Sivavittanala_1-1747821783233.png

 

I want to upload above format skill data into primary resource skill field. this field is refer to cmn_skill table.

1 ACCEPTED SOLUTION

Hello @Siva vittanala ,

 

So you have added this as an onAfter Transform Script on the Transform Map that has "Employee Profile" as the target table, correct?

 

If so then you need to change the line that assigns the "userId" value, because "target" is the Employee Profile record and the user is referenced in its "user" field:

 

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

    var skillNames = source.getValue('u_user_skill').split(',');
    var userId = target.getValue('user');

    skillNames.forEach(skillName => {
        var gr = new GlideRecord('sys_user_has_skill');
        gr.addQuery('user', userId);
        gr.addQuery('skill.name', skillName);
        gr.query();
        if (gr.hasNext()) return;
        gr.initialize();
        gr.setValue('user', userId);
        gr.setDisplayValue('skill', skillName);
        gr.insert();
    });

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

 

Your script was assigning the sys_id of the Employee Profile to "userId", which resulted in the issue.

 

Regards,

Robert

 

View solution in original post

8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

@Siva vittanala 

then don't give field map, handle everything using onBefore transform script

for each row get the number of skills how many are there in that excel column and create those many records into target table using for loop and GlideRecord

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

Could you please provide script.

@Siva vittanala 

please check response from @Robert H 

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

Robert H
Mega Sage

Hello @Siva vittanala ,

 

That is not possible. The Primary Resource Skill field is a reference field and can only contain a single skill record.

 

If you want to link multiple skills to a person you have to load your data into the User Skills [sys_user_has_skill] table.

You can use this solution with a few adjustments. It's meant for the Group Roles, but you can simply change the table and field names as per your requirements.

 

Regards,

Robert