Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

transformation map to import user and create HR Profile

Dimitri Destin
Tera Guru

Hi All,


I'm trying to update a transformation map on user table to create HR Profile in using onAfter script.

transformation map is in global scope (because I import on sys_user table)


No HR profile is created and I can find in the log "Source descriptor is empty while recording access for table sn_hr_core_profile: no thrown error"


Is this a problem with cross scoped access?

How can I solved this?


Thank you in advance.

 

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


//Create HR profile if doesn't exist
var userId = target.sys_id;
checkAndCreateHRProfile(userId);

function checkAndCreateHRProfile(userId) {
var grHrProf = new GlideRecord('sn_hr_core_profile');
grHrProf.addQuery('user', userId);
grHrProf.query();
if (!grHrProf.next()) {
// grHrProf.setValue('user', userId);
// grHrProf.insert();
var hrProfile = new hr_Profile();
hrProfile.createProfileFromUser(userId);
}
}
})(source, map, log, target);




13 REPLIES 13

You just opened up a lot of GDPR/PII info for any process in ServiceNow to read and write 😉

Indeed, you are right. I was so happy that it worked that I didn't think about it.
I'm still looking....

 

Have you tried creating a 2nd Transform Map in scope Human Resources: Core?

Finally, we have create a new script include in Human Resources Core, accessible from all application scopes. In this script, we have only one function, using the createProfileFromUser function of hr_profile script.

 

In the onAfter script of the transformation map, we call this new script.

 

Thank you everyone