How to run "Populate primary resource attributes" from background script
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I have to create a Action in flow designer, where I will be passing user sys_id. I want to trigger "Populate primary resource attributes".
Labels:
12 REPLIES 12
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I'm trying below script:
// If you only have sys_user.sys_id, resolve the profile first:
var userSysId = '001701001b881d94f7590f6cdc4bcb5a';
var prof = new GlideRecord('sn_employee_profile');
prof.addQuery('user', userSysId);
prof.setLimit(1);
prof.query();
if (prof.next()) {
gs.info('Done for profile ' + prof.getUniqueValue());
svc.populatePrimaryAttrsForResource(prof.getUniqueValue());
gs.info('Done for profile ' + prof.getUniqueValue());
var cfg = {
"primary_resource_group": {"userRefField":"user"},
"primary_resource_skill": {"userRefField":"user"},
"primary_resource_role": {"userRefField":"user"}
};
var svc = new global.ResourceProfileSyncServiceSNC(cfg);
} else {
gs.warn('No employee profile found for user ' + userSysId);
}
I'm getting below error:
I added Restricted caller access, Ran the script in Employee profile scope. Still getting error like below.
Source descriptor is empty while recording access for table sn_employee_profile: no thrown error
Security restricted: Read operation on table 'sn_employee_profile' from scope 'Global' was denied because the source could not be found. Please contact the application admin.
Security restricted: Read operation on table 'sn_employee_profile' from scope 'Global' was denied. The application 'Employee Profile' must declare a Restricted Caller Access privilege. Please contact the application admin to update their access requests.
*** Script: No employee profile found for user 001701001b881d94f7590f6cdc4bcb5a
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
check if any Restricted caller access is blocking
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I have given access in "Restricted caller access priveliges"
