restart flow designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2024 06:09 AM
Hi all,
i'm try to cancel the existing flow and try to retrigger a flow i write a UI action, currently i'm able to cancel the flow and restarting the flow again approvals getting triggered below script i have written
UI action:
(function() {
var req = new GlideRecord('sc_request');
req.addQuery('sys_id', current.request);
req.query();
if (req.next()) {
req.setWorkflow(false);
req.active = true;
req.request_state = 'requested';
req.update();
// Restart workflow for REQ (Traditional Workflow)
new Workflow().restartWorkflow(req);
}
// Find and cancel related flow context records for RITM
var grFlowContext = new GlideRecord('sys_flow_context');
grFlowContext.addQuery('source_record', current.sys_id.toString());
grFlowContext.orderByDesc('sys_created_on');
grFlowContext.query();
while (grFlowContext.next()) {
sn_fd.FlowAPI.cancel(grFlowContext.sys_id.toString(), null);
}
// Restart the Flow Designer flow for RITM
try {
// Restart the flow context for RITM
sn_fd.FlowAPI.getRunner().restartFlowFromContext(grFlowContext.sys_id.toString(), null);
} catch (ex) {
gs.error('Error occurred: ' + ex.getMessage());
}
// Update the RITM record
current.active = true;
// current.state = '1'; // Set to active
current.update();
// Add a work note to the RITM
current.work_notes = 'Request has been restarted by ' + gs.getUserDisplayName();
current.update();
// Redirect to the current RITM record
action.setRedirectURL(current);
})();
and i am sharing my requirement as well
Create UI action to restart cancelled/rejected Requested Item
Name: Restart
Available when state = Closed Skipped or Closed Incomplete
Requires role Catalog Admin
If Parent REQ is closed, mark as active and set state to Pending Approval. Restart workflow
Set RITM state to 1 and active to true
Restart (Or re-run) flow associated with the RITM
Add work note: Request has been restarted by (current user display name
i'm sharing my screenshot:screenshot of flow context after rejecting the approval
After click on ui action a new approval is generated
screenshot of flow context after new approval is generated
screenshot of flow context after approves the approvalWhen approval is approver the flow is not running properly and skipping the to created a sc task and completed stages
please guide me
Thank you,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2024 12:07 AM
Hello @rognomolta,
For similar kind of issues, please refer to the links below:
https://www.servicenow.com/community/itsm-articles/restart-retrigger-a-flow-designer/ta-p/2306116
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0855865
If it is helpful, please mark it as helpful and accept the correct solution. In future, it might be helpful for someone to refer to this solution.
Thanks & Regards,
Abbas Shaik
