- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2024 01:05 PM
When a new hire gets rescinded in our HR system, we would like to delete/rescind the HR Profile and also the onboarding case lifecycle event.
i know this can be done manually, however, is there an API that the HR system can call and cancel this hire and LCE automatically?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2024 09:03 PM
Hi @Casey4 ,
I would not recommend data deletion by API as a best practice solution under any circumstances, as deletion of data using this process will result in anomalies\orphaned relationships and would recommend that you use the API to set the sys_user record inactive and\or locked out, and then use an after BR to clean up assigned roles\groups etc. You could then archive inactive users after X months.
If you are still keen to delete, here is a sample script:
//Set query and uncomment gr.deleteMultiple()
var gr = new GlideRecord('sn_hr_core_profile');
gr.addQuery('sys_created_on', '>', "13-05-2018" );
gr.query();
gs.info("Returned Record" + gr.getRowCount());
// gr.deleteMultiple();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2024 09:03 PM
Hi @Casey4 ,
I would not recommend data deletion by API as a best practice solution under any circumstances, as deletion of data using this process will result in anomalies\orphaned relationships and would recommend that you use the API to set the sys_user record inactive and\or locked out, and then use an after BR to clean up assigned roles\groups etc. You could then archive inactive users after X months.
If you are still keen to delete, here is a sample script:
//Set query and uncomment gr.deleteMultiple()
var gr = new GlideRecord('sn_hr_core_profile');
gr.addQuery('sys_created_on', '>', "13-05-2018" );
gr.query();
gs.info("Returned Record" + gr.getRowCount());
// gr.deleteMultiple();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2024 09:12 AM
@Community Alums thanks - can we use the script to inactivate: the challenge here being: how would Servicenow ingest the trigger based on the rescind in another system?