Data should be deleted automatically after mentioned time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2023 01:22 AM
Hello all,
Requirement is to archive data after some years and then delete the data after archiving for some years.
I have checked how archival of records is done in servicenow but that is for a complete record and only one archival rule can be used on a table.
The tricky part for me here is, we don't want to archive complete records, we have different fields on our record, and some fields needs to be archived after 3 years, some after 8 years, and then after archival, if nothing updated, they should be deleted. How do I achieve this field level archival and deletion rather than whole record archival? I know this might require custom scripting but not sure what and how to achieve this. Please help!!!
Regards,
Ath.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2023 01:48 AM
Archival takes place on a record (row) level and not on a field (column) level. So the question would be, what is the actual requirement regarding "archiving some field (only) after x years"? How should the original record look like after that? For example, if you were to "archive" only the assignment groups & assigned to fields from incidents 3 years after they are closed, what does it mean? Would you need to remove the values from those fields in the original incident, and store a reference to it somewhere else (like an archive, although it will not be that)?
What I am thinking is, you could create your own logic for this, by creating a custom table where you would store these "partial archives", and have a scheduled flow (or script if you prefer) that would run every night (or week, etc.) to create partial archive records in your custom table for records that match that criteria, and also update the original record if needed. After the (original) record meets the criteria, another scheduled flow/job would take care of moving the rest of the fields to the matching record in your custom table. At the end, you would configure archival/destroy rules on your custom table, and not on the original one.
This is one idea to consider, as the standard archival mechanism would not allow this granularity I'm afraid.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2023 02:05 AM
Hi @Laszlo Balla ,
Thank you!
yes that is correct, we will need to remove the values from those fields in the original incident, and store a reference to it somewhere else so that if our agents want to see them back within the mentioned time period, we can still have them. But I am afraid we might not be allowed to create a new table for this purpose due to some licensing issues. Could you please let me know if there is any alternative for this?
Also, I would like to see how your approach can be implemented (just in case they agree with table creation or for my knowledge building). I am able to understand the concept but at the moment I couldn't think straight. I am so sorry to bug you but if you could provide me some sample flow or script with which your approach can be implemented, it would be much appreciated!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2023 02:10 AM - edited 04-17-2023 02:11 AM
Hi,
You are correct that this requirement will require custom scripting to achieve field-level archival and deletion rather than whole record archival. Here are some steps you can follow to implement this requirement:
Define the fields that need to be archived after a certain number of years. This could be done through a field-level metadata or by adding a custom field to track the archival date for each field.
Create a script that identifies records that meet the archival criteria (based on the archival date of each field) and copies the values of the archival fields to a separate archival table. This script can be scheduled to run periodically to ensure that records are archived at the appropriate time.
Once the records have been copied to the archival table, another script can be created to delete the records from the original table if they have not been updated for a certain number of years. This script can also be scheduled to run periodically to ensure that records are deleted at the appropriate time.
To ensure that the archival and deletion process is auditable and traceable, you may want to consider adding a log or audit trail to track when records were archived and deleted.
Finally, it's important to thoroughly test the archival and deletion process to ensure that it is working as expected and does not cause any unintended data loss or errors.
Note that this is a complex requirement that will require careful planning, testing, and monitoring to ensure that it is implemented correctly and meets your organization's data retention policies and regulatory requirements. You may want to consult with a ServiceNow expert or a data management specialist to ensure that your implementation is compliant with best practices and industry standards.
Thanks,
Rahul Kumar