- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2024 12:20 AM
Hi All,
I have a request where I have to add few filters and mark change request as closed.
Conditions are:
All those change request which are not updated from 10 days.
there are no active change task under it, or they have no change task at all.
All such change where multiple ctasks are there with some active and some inactive shall be ignored. Only those with all inactive ones will be considered.
I tried gliding to ctask, checking with all filters , but confused with how to check for changes without a change task.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2024 01:06 AM
Hi @Annirnita Dash1 ,
You can create a schedule job and set run as daily.
Use below script to close the change based on your condition.
var gr = new GlideRecord('change_request');
gr.addEncodedQuery('sys_updated_onRELATIVELT@dayofweek@ago@10');
gr.query();
while (gr.next()) {
var gr2 = new GlideRecord('change_task');
gr2.addEncodedQuery('change_request=' + gr.sys_id + '^active=true');
gr2.query();
if (!gr2.next()) {
gr.state = 3;
gs.setWokflow(false);
gr.update();
}
}
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2024 12:34 AM
I have no idea how this can be done, but you can create a report for same upto some extent as per my experience
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
11-04-2024 12:37 AM
@Dr Atul G- LNG , thanks for the reply.
I have to mark this change as closed, so report will only give me data.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2024 12:41 AM
Yes correct, report will give only data. Might be use that data in flow to close teh changes.
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
11-04-2024 01:06 AM
Hi @Annirnita Dash1 ,
You can create a schedule job and set run as daily.
Use below script to close the change based on your condition.
var gr = new GlideRecord('change_request');
gr.addEncodedQuery('sys_updated_onRELATIVELT@dayofweek@ago@10');
gr.query();
while (gr.next()) {
var gr2 = new GlideRecord('change_task');
gr2.addEncodedQuery('change_request=' + gr.sys_id + '^active=true');
gr2.query();
if (!gr2.next()) {
gr.state = 3;
gs.setWokflow(false);
gr.update();
}
}
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------