Skip to content

Instantly share code, notes, and snippets.

@ChecksumFailed
Last active January 18, 2022 18:24
Show Gist options
  • Save ChecksumFailed/96e6790307c4902d3746ba1dbce1d639 to your computer and use it in GitHub Desktop.
Save ChecksumFailed/96e6790307c4902d3746ba1dbce1d639 to your computer and use it in GitHub Desktop.
(function() {
var comment = "Workflow cancelled by " + gs.getUserDisplayName();
new WorkflowApprovalUtils().cancelAll(current, comment);
new Workflow().restartWorkflow(current);
current.work_notes = comment;
//cancel current flow context and start new
if (!current.cat_item.flow_designer_flow.nil() && !current.flow_context.nil()) {
sn_fd.FlowAPI.cancel(current.flow_context.sys_id.toString(), 'Cancelling Flow');
var inputs = {
"request_item": current
};
var flowName = current.cat_item.flow_designer_flow.sys_scope.scope.toString() + "." + current.cat_item.flow_designer_flow.internal_name.toString();
var newContext = sn_fd.FlowAPI.startFlow(flowName, inputs);
current.flow_context = newContext;
}
current.update();
gs.addInfoMessage(comment);
action.setRedirectURL(current);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment