Maintaining old reports (last run < 5 months)

Harsha Pappala
Kilo Sage

Hi Everyone, 

 

We have a health scan from ServiceNow, where we have to handle reports which were run more than 3 months back. Trying to come up with an automatic solutions, where to send emails to reports owners and delete them after some days. 

 

But we want to keep a record of such deleted reports, if someone raises a issue we want to retrieve information about the report, which helps in creating it again. Please advise  

4 REPLIES 4

AnveshKumar M
Tera Sage
Tera Sage

Hi @Harsha Pappala 

You can check report_stats table for the list of reports and when they are run.

So you can create a scheduled job, Glide sys_report table to get the list of reports and check each report against report_stats table. If you find an entry in it for that report, you can get when it was ran from the last_run field.

 

If there is no entry means it was never run.

 

You can take the decision accordingly and send the email to the respective owner.

 

Coming to the second part,

 

While sending the email you can attach the filters, type, column and title of the report, otherwise if you want it stored in your instance you can create a custom table and store all the data related to the report in that custom table.

 

Let me know if you need more help.

 

Please mark my answer helpful and accept as a solution if it helped 👍

Thanks,
Anvesh

Hi @AnveshKumar M , 

Thank you for the response, we have already created a flow which sends out the emails and later deletes if the last run does not change. 

 

For more info of others, I have created database view of report_stats, sys_report table on which I am running this flow. We want to store the names of the reports being deleted

 

We have cases where the owner of report has left, but we want to preserve the name of the report and details as such. 

@Harsha Pappala Flow is great choice.

 

If you want to store name and other details permanently, custom table is the only option available as far as I know.

Thanks,
Anvesh

Sainath N
Mega Sage
Mega Sage

@Harsha Pappala : This can be done easily via flow designer. Scheduled flow can be configured on [report_stats] table on "Last Run" column [Ex; Last run relative 150 days ago]. Below is the snip of the flow to give you some idea.

 

sainathnekkanti_0-1702956258036.png

This flow notifies the user that they must take action, and you can configure another flow or add logic here to check if the last run is still the same after a few days. If this is the case, you can proceed with the deletion and archive it in some table for future references.

 

Note: Because we are dealing with record deletion, we must thoroughly test the functionality in DEV.

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

 
Regards,
Sainath N