- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2024 06:56 AM - edited 01-04-2024 07:01 AM
Hi all.
I have the following scheduled job script that should look for a specific catalog item and then clear out certain variables. The variables should only be cleared on request items that have been closed for 30 days.
My issue is that how do I get the script to capture request items that may have been closed a year or so ago in the platform.
End goal is for this script to run where the closed date is at least 30 days ago.
I feel I need to compare the closed date of the request item with today's date and if greater then 30 days clear the variables.
var q = 'cat_item=d203fe1fdb87fb00fd7db34ffe961923^closed_at<javascript:gs.beginningOfLast30Days()';
var gr = new GlideRecord('sc_req_item');
gr.addEncodedQuery(q);
gr.query();
while (gr.next()) {
gr.variables.alternative_address = '';
gr.variables.sc_street_name_and_number = '';
gr.variables.sc_zip_code = '';
gr.variables.sc_city = '';
gr.variables.other_location = '';
gr.variables.other_delivery_address = '';
gr.variables.alternative_address_MACZ = '';
gr.variables.other_address = '';
gr.setWorkflow(false);
gr.autoSysFields(false);
gr.update();
}
Regards.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2024 06:59 AM
I think you need everything which was closed before last 30 days, for that particular catalog item
If so, then this should work
EncodedQuery:
cat_item=970949824f69f70099f1b3728110c7d6^closed_at<javascript:gs.beginningOfLast30Days()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2024 07:04 AM
It's to remove personal information. For example where someone has provided an alternative address for something to be collected/delivered.
Request item is submitted --> Request item is worked on and closed --> 30 days later variables should be cleared.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2024 07:12 AM
Hi @arobertson
Better to hide those via UI policy instead of removing. or use ACL.
@Anurag Tripathi Thoughts please.
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
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2024 07:14 AM
I usually don't like to delete it too , because it may come back form a compliance / Data retention policy side of things and bite in future, but if the data contains pii it might be important to delete. But be sure to check the company policy on the same.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2024 07:31 AM
Hi,
As an alternative, you can create a Flow that does the same. No scripting required.
Providing a simple example below.