- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2025 03:32 AM
Hi everyone,
We have schedule job which runs everyday to delete HR profiles created for Contingent workers.
Now we have requirement to exclude contingent workers from getting their HR profile removed if they are having
1.sn_hr_core.basic role ( contractors who are agents)
2. 'employeeType' = 'ANC' (this is a field on HR profile table)
How to include above condtions
cleanUpHRProfiles();
function cleanUpHRProfiles(){
// Cleanup all HR profiles where WORKDAY ID is EMPTY
var encodedstr1 = "correlation_idISEMPTY";
var hrObj = new GlideRecord("sn_hr_core_profile");
hrObj.addEncodedQuery(encodedstr1);
hrObj.setLimit(1000);
hrObj.deleteMultiple();
}
suggest me best approach
TIA
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2025 05:07 AM
use this and give correct value for Employee Type
cleanUpHRProfiles();
function cleanUpHRProfiles() {
// Cleanup all HR profiles where WORKDAY ID is EMPTY
// form the correct query and paste here
var encodedstr1 = "user.roles=sn_hr_core.basic^correlation_idISEMPTY^employment_type=contingent";
var hrObj = new GlideRecord("sn_hr_core_profile");
hrObj.addEncodedQuery(encodedstr1);
hrObj.setLimit(1000);
hrObj.deleteMultiple();
}
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
‎02-07-2025 05:07 AM
use this and give correct value for Employee Type
cleanUpHRProfiles();
function cleanUpHRProfiles() {
// Cleanup all HR profiles where WORKDAY ID is EMPTY
// form the correct query and paste here
var encodedstr1 = "user.roles=sn_hr_core.basic^correlation_idISEMPTY^employment_type=contingent";
var hrObj = new GlideRecord("sn_hr_core_profile");
hrObj.addEncodedQuery(encodedstr1);
hrObj.setLimit(1000);
hrObj.deleteMultiple();
}
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