I need to know how to close change request after 24 hours once all the change tasks has been closed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2022 08:16 AM
Hi,
I have a requirement that when all the change tasks where closed then automatically after 24 hours change request need to be closed. Can I know how can I achieve this. Please help me with the code or some one please guide on this.
Thanks,
Lohith
- Labels:
-
Change Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2022 08:33 AM
You need the following logic in a scheduled job, for example running once every hour:
- Query the change_request table for changes that are not closed
- For each on of them query the change_task table for tasks related to this change which are not closed.
----If you find any, continue to the next change
----If you do not find any, then check when was the last change_task closed (e.g. get the closing time). Compare it with the current time (gs.now()). if the difference is more than 24 hours - set the change state to closed.
- Continue to the next change_request.
This will require some scripting, but it is not a rocket science.
Please mark Correct and Helpful if my answer helps you resolve your issue. Thanks!
Martin Ivanov
Community Rising Star 2022
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
08-03-2022 08:51 AM
Hi Lohith,
I would suggest you to use Flow Designer to achieve this.
You have "Wait for Duration" action in flow designer to give the 24 hours time.
You can check this link. That is not same requirement but will help you to setup flow.
Mark as correct and helpful if it solved your query.
Regards,
Sumanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2022 06:17 AM
Feel free to reach out if you have further questions or else you can mark an answer as correct and helpful to close the thread so that it benefits future visitors also.
Regards,
Sumanth

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2022 11:17 PM
Please mark Correct and Helpful if my answer helps you resolve your issue.
Тhis will close the thread and other users may also benefit from it.
Thanks!
Martin Ivanov
Community Rising Star 2022
Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Martin Ivanov
ServiceNow MVP 2023, 2024