transformation map to import user and create HR Profile

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2023 03:48 AM
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-26-2023 09:25 AM
You just opened up a lot of GDPR/PII info for any process in ServiceNow to read and write 😉

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2023 03:18 AM
Indeed, you are right. I was so happy that it worked that I didn't think about it.
I'm still looking....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2023 04:54 AM
Have you tried creating a 2nd Transform Map in scope Human Resources: Core?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2023 04:56 AM
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