Quick Help: Can anyone pls tell me calling a flow designer from UI action is possible?

Prakash1to
Mega Expert

Hi,

We are trying to trigger both On boarding and detailed assessments from business service form once it is created and we provide this flexibility through a UI actions (buttons). We configured triggers and actions in flow designer.

 

But is there anyway to call a flow in UI action script?

Urgent help is required.

1 ACCEPTED SOLUTION

kushal Tayade
Mega Guru

 

Use below code in the UI action

try {
var flowInputs = {};
flowInputs['current'] = current;
flowInputs['table_name'] = current.getTableName();

var result = sn_fd.Flow.startAsync('SCOPENAME.FLOWNAME', flowInputs);
//The Sys ID of a flow execution (contextId)
var contextId = result.contextId;

} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}

View solution in original post

7 REPLIES 7

kushal Tayade
Mega Guru

 

Use below code in the UI action

try {
var flowInputs = {};
flowInputs['current'] = current;
flowInputs['table_name'] = current.getTableName();

var result = sn_fd.Flow.startAsync('SCOPENAME.FLOWNAME', flowInputs);
//The Sys ID of a flow execution (contextId)
var contextId = result.contextId;

} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}

Hi @kushal Tayade,

I have added this in my UI action but the flow still needs a trigger condition to get activated.

My aim was not to add any trigger condition in the flow and only this UI action should trigger it.

Can you please let me know how to handle this.

Thankyou

Mario Garcia
Tera Contributor

This is the one that finally worked for me.

 

 

var gr = new GlideRecord('sys_flow_context');
gr.addQuery('source_record', current.sys_id);
gr.query();
if (gr.next()) {
    var url = '$flow-designer.do?sysparm_nostack=true#/operations/context/' + gr.sys_id.toString();
    action.setRedirectURL(url);
} else {
    gs.addErrorMessage("Record not found");
    action.setRedirectURL(_blank);
    gs.info(gr.sys_id);
}