how to trigger a flow from an UI page

Gunda Vamshi kr
Tera Contributor

Hi, I have an UI Page called "Request Approval" on Incident form whenever user clicks it, it pops up a dialog box to input 'approver' then runs workflow in the back end, I converted the workflow into a flow and now I want to call the flow instead of workflow, how can I call flow from a UI page??

This is the script that calls the workflow

if (cancelled == "false" && (user != "")) {
var newApr = new GlideRecord('sysapproval_approver');
newApr.initialize();
newApr.approver = user;
newApr.sysapproval = incident;
newApr.state = 'requested';
newApr.insert();

var inc = new GlideRecord('incident');
inc.get(incident);

var w = new Workflow();
if(w.hasWorkflow(inc)) {
var appr = new GlideRecord('sysapproval_approver');
appr.addQuery('sysapproval', inc.getValue('sys_id'));
appr.query();
while(appr.next()) {
appr.wf_activity = '';
appr.update();
}
w.deleteWorkflow(inc);
}
var z = new Workflow();
var context = z.getWorkflowFromName('Incident Manual Approvals');
var wfgo = z.startFlow(context, inc, 'insert');

if (wfgo != null) {
inc.u_context = wfgo.sys_id;
inc.update();
}
}
response.sendRedirect("incident.do?sys_id=" + incident);  

1 REPLY 1

Community Alums
Not applicable