- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2023 01:48 AM
Hi All,
I want to cancel the pending workflows of one particular workflow, if the number exceeds the amount of 1000 pending workflows, then it will cancel from the oldest one from the schedule job.
Can anyone please help me out on this ?
Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2023 05:36 AM
@Ankur Bawiskar - Hi, I tested the below script, It worked. Thanks for your support.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2023 07:48 AM
Glad to know.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2023 03:23 AM
didn't get your requirement?
cancel the pending workflows of 1 particular workflow?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2023 03:39 AM
@Ankur Bawiskar - Hi, I am having one workflow named "xyz", I want to cancel all the pending workflows triggered for the same workflow. But it will only cancel when the total record number is more than 1000 and it will cancel from the oldest workflow triggered.
If its not clear, Please let me know.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2023 03:52 AM
got it
then query workflow context table and cancel it in ascending order by using orderBy on sys_created_on
Sample script to cancel workflow
var gr = new GlideRecord('incident');
gr.get('sys_id');
var workflow = new Workflow();
workflow.cancel(gr);
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2023 04:04 AM
@Ankur Bawiskar - Thanks, How to check the total count is more than from 1000, I got the total count by getRowCount(). I have tried the below,