- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2022 04:27 AM
Hi Team,
We had an issue with workflow so requests were not closed properly & we have fixed that issue. But want to close the old records.
RITM state is set to Closed Complete on them but Stage is still showing as Fulfillment and REQ is also active.
How can we set Stage (field type - workflow) field to Completed and close out REQ using script?
Thank you.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- 3,212 Views

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2022 04:51 AM
var grReqItems = new GlideRecord('sc_req_item');
grReqItems.addQuery('stage', '!=', 'complete');
grReqItems.query();
while(grReqItems.next()){
grReqItems.setValue('stage', 'complete');
grReqItems.update()
}
Please note that this will close all RITMS that are not closed. If want to close only specific items, please provide the query and I will provide you with the script.
Mark Correct and Helpful if appropriate. Thanks
Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Martin Ivanov
ServiceNow MVP 2023, 2024

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2022 04:51 AM
var grReqItems = new GlideRecord('sc_req_item');
grReqItems.addQuery('stage', '!=', 'complete');
grReqItems.query();
while(grReqItems.next()){
grReqItems.setValue('stage', 'complete');
grReqItems.update()
}
Please note that this will close all RITMS that are not closed. If want to close only specific items, please provide the query and I will provide you with the script.
Mark Correct and Helpful if appropriate. Thanks
Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Martin Ivanov
ServiceNow MVP 2023, 2024
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2022 05:23 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2022 10:28 PM
I have my own name for this Stage column, "List view Stage". my way of controlling this is as below:
- go to your workflow
- open any activity
- under the name, there should be a Stage input box. this controls what you see on your lists.
- select a proper stage for all or some of your activities you have in workflow. repeating a same stage does not produce duplicate views.
I hope that helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2022 05:30 AM
If you have SC_Task records, related to the ritms, you have to complete these as well. Is this screenshot from REQ or RITM?
Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Martin Ivanov
ServiceNow MVP 2023, 2024