Getting org.mozilla.javascript.NativeArray@79343f70 Error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2024 03:53 AM
Hi Team,
Iam running fix script to get the details of manager from HR profile and set it to journey table.
While running iam getting org.mozilla.javascript.NativeArray@79343f70 as log Any suggestion?
Fix script:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2024 05:38 AM
@Ankur Bawiskar , I just saw Journey owner referencing to HR profile not user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2024 05:55 AM
then you should return HR profile record sysId and not user record for sys_user
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 10:24 PM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2024 06:09 AM
You are ultimately trying to update the sn_jny_journey.manager, which is a reference field, so this is only one value, which is a sys_id from the HR Profile table, not multiple display values. These scripts will probably get you closer to what you want to do.
Fix Script:
var managerUpdate = new GlideRecord('sn_jny_journey');
managerUpdate.addEncodedQuery('numberINJNY00002061,JNY00002062');
managerUpdate.query();
while (managerUpdate.next()) {
var user = new sn_hr_core.getHiredate().getManager(managerUpdate.employee);
gs.info('PTEST2' + user)
managerUpdate.manager = user;
managerUpdate.update();
}
Script Include:
getManager: function(emplye) {
var answer = '';
//get the HR Profile record of the Employee
var hrProfileGR = new GlideRecord('sn_hr_core_profile');
hrProfileGR.addQuery('sys_id', emplye);
hrProfileGR.query();
if (hrProfileGR.next()) {
var manager = hrProfileGR.getValue('user.manager');
gs.info('Manager User table Sys_ID: ' + manager);
//get the HR Profile record of the Employee's manager
var hrProfileMgr = new GlideRecord('sn_hr_core_profile');
hrProfileMgr.addQuery('user', manager);
hrProfileMgr.query();
if (hrProfileMgr.next()) {
answer = hrProfileMgr.sys_id;
gs.info('Manager Profile Sys_ID: ' + answer);
}
return answer;
}