- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-09-2022 08:50 PM
I have designed custom workflow that send GET request to Jenkins at multiple stage. how can i stop the execution of rest workflow if there is error at previous stage. #workflow #flow
Solved! Go to Solution.
- Labels:
-
Task Communications Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2022 02:13 AM
you can cancel the current workflow context using script.
Sample script is available in docs
var grContext = new GlideRecord("wf_context");
grContext.get(context_sys_id);
var grReq = new GlideRecord("sc_req_item"); // add your table on which the workflow is built
// The current record may not exist, make sure it exists before modifying it.
if (grReq.get(grContext.id)) {
grReq.comments = "The workflow has been cancelled due to error in API.";
grReq.update();
}
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-09-2022 10:03 PM
Hi,
you can check the API response and based on success or failure you can take the output to End activity.
Use if activity to check API response -> Is success?
output of yes -> other activity
output of no -> End activity
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2022 01:57 AM
Hi Ankur, Thank you for quick response.
i had thought of this however since the workflow is very huge and at each stage Jenkins is called so pointing to end with each stage will make workflow design more complex. if there any way such that if there is error workflow should stop at that point.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2022 02:13 AM
you can cancel the current workflow context using script.
Sample script is available in docs
var grContext = new GlideRecord("wf_context");
grContext.get(context_sys_id);
var grReq = new GlideRecord("sc_req_item"); // add your table on which the workflow is built
// The current record may not exist, make sure it exists before modifying it.
if (grReq.get(grContext.id)) {
grReq.comments = "The workflow has been cancelled due to error in API.";
grReq.update();
}
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2022 10:06 PM
Thank you Ankur😀