Deletion of bulk records for the Legacy sn_hr_core_case_relations table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2024 04:51 AM
Hi everyone,
We are not using the legacy sn_hr_core_case_relations table in our instance anymore, but we have bulk records from the legacy sn_hr_core_case_relations table in our instance which was migrated in a data migration process, any idea on how can we delete these records? Background scripts or manual deletion is not working as it's unable to find the table in the instance.
Thank you in advance. 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2024 05:08 AM
Hi @Shaqeel , the table is not present in our instance. 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2024 05:17 AM
Hi @Simanta27
I found this:
To delete bulk records from a table in ServiceNow, even if the table is not visible in the instance, you can use a background script. Here are the steps:
1. Navigate to "System Definition > Scripts - Background" in your ServiceNow instance.
2. In the Run script text area, you can write a script to delete the records.
Here is a sample script:
javascript
var gr = new GlideRecord('sn_hr_core_case_relations'); // replace with your table name gr.addQuery('condition', 'value'); // replace 'condition' and 'value' with your condition
gr.query();
while (gr.next()) {
gr.deleteRecord();
}
3. Click 'Run script'. This will delete all the records that match the condition you specified.
Please note:
- Replace 'sn_hr_core_case_relations' with the actual table name.
- Replace 'condition' and 'value' with the actual condition you want to use to filter the records to delete. - Be careful when running this script, as it will permanently delete records from the table. It's recommended to test on a sub-production instance first.
- If the table is not visible, make sure you have the correct access rights to view and modify the table.
- If the table is large, this operation may take some time and could impact system performance. Consider running the script during off-peak hours.
Regards
Shaqeel
***********************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful." This action benefits both the community and me.
***********************************************************************************************************************
Regards
Shaqeel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2024 05:20 AM
Hi @Shaqeel , the issue is that the table is not there in the instance only.
So the query is throwing an error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2024 05:21 AM