Business rule to start flow designer

venkyk1309
Tera Contributor

Hi all,

I have written a script in business rule to start the flow designer 
condition after - insert & update
script :-

(function executeRule(current, previous /*null when async*/ ) {


var flowSydId = catGR.getValue('flow_designer_flow');
gs.info("&&0 " + flowSydId);

var inputs = {};
inputs.requested_item = current;
inputs.requested_item.sys_id = current.sys_id;
inputs.table_name = current.getTableName();

try {
var runner = sn_fd.FlowAPI.getRunner()
.flow(flowSydId)
.inBackground()
.withInputs(inputs)
.run();

var contextId = runner && typeof runner.getContextId === 'function' ? runner.getContextId() : '(not returned)';

gs.info("&&4 Flow triggered for Requested Item: " + current.number +
" | Flow Sys ID: " + flowSydId +
" | Context ID: " + contextId);

} catch (e) {
gs.error("&&5 Error triggering flow: " + e.message);
}


})(current, previous);

I'm able to retrieve the Flow Designer flow sys_id correctly when the catalog item is changed on a request. The issue arises when switching from an item that uses a Workflow to one that uses Flow Designer — in such cases, the RITM gets stuck and doesn't trigger approvals.

To address this, I wrote a script to manually start the Flow Designer flow when the item changes. However, it's not working as expected.

Do you have any suggestions or solutions for handling item changes where the original item runs on Workflow and the new one runs on Flow Designer? Ideally, I want the flow to trigger properly and continue the approval process without getting stuck.

0 REPLIES 0