- 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 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:17 AM
That is what I'm using now. I think I was getting myself confused and it is actually working as expected.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2024 07:24 AM
So is this thread answered?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2024 07:00 AM
Hi @arobertson
What is use case of same? After closing changing or removing value is not a best pratcie.
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]
****************************************************************************************************************