Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi everyone please i would like to write a BR to exclude exteranl users from seeing the offboarding case
here is the script but still didn t work
(function executeRule(current, previous) {
var userId = gs.getUserID();
gs.info('[HR VISIBILITY] Logged-in user sys_id = ' + userId);
// Get HR Profile
var hrProfile = new GlideRecord('sn_hr_core_profile');
hrProfile.addQuery('user', userId);
hrProfile.query();
if (!hrProfile.next()) {
gs.info('[HR VISIBILITY] No HR Profile found for user');
return;
}
gs.info('[HR VISIBILITY] HR Profile found: ' + hrProfile.sys_id);
// Country
var country = hrProfile.u_legal_entity.u_country.getDisplayValue();
gs.info('[HR VISIBILITY] Country = ' + country);
if (country !== 'Spain') {
gs.info('[HR VISIBILITY] User is NOT in Spain → exiting');
return;
}
// Employment type
var employmentType = (hrProfile.getValue('employment_type') || '').toLowerCase();
gs.info('[HR VISIBILITY] Employment type = ' + employmentType);
var excludedTypes = [
'300000000123199',
'300000000120757',
'subcontractor'
];
if (excludedTypes.indexOf(employmentType) === -1) {
gs.info('[HR VISIBILITY] Employment type is NOT external → exiting');
return;
}
gs.info('[HR VISIBILITY] Spain external user detected');
// Exclude Offboarding
current.addQuery('hr_service', '!=', '58d30358c3f4d2505c227e53e40131ed');
gs.info('[HR VISIBILITY] Excluding Offboarding cases from query');
})();
Solved! Go to Solution.
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi there @ghitabahaj
why BR? can u try ACL
Use a Read ACL on sn_hr_le_case to deny access when:
HR Service = Offboarding
User is external (employment type / profile condition)
Or apply HR Criteria / User Criteria on the Offboarding HR Service
☑️ If this helped, please mark it as Helpful or Accept Solution so others can find the answer too.
Kind Regards,
Azar
Serivenow Rising Star ⭐
Developer @ KPMG.
Kind Regards,
Azar
Serivenow Rising Star ⭐
Developer @ KPMG.
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Hi i actually ended up creating an ACL to deny access, cause none of the things i've did worked
