Could Not call a Flow from BR

Lucky1
Tera Guru

Hello all,

 

I have created a flow designer with a trigger condition like, Updated and the table name selected is Business Application and Condition is: Description contains Test 123.

and later I am triggering approvals from the Actions.

 

My requirement is, when ever any business application status is changed to Retired, then it should trigger approval to Business owner and in the same time, the status should be set to it's previous value only, but not to Retired. and only once the approver approves, then the state has to be changed to Retired, or else, the state will be set to previous state only.

 

So, for this I have written a Before Update BR, condition is: Status changed to Retired. and in the advanced script: 

Lucky1_0-1755083140982.png

 

the log Inside BR Try is coming up but the next log, Flow triggered successfully is not coming up and also, when I check the executions, the flow has not been executed.

 

Please help.

 

 

Regards,

Lucky

 

7 REPLIES 7

Shashank_Jain
Kilo Sage

@Lucky1 ,

 

Flow Designer triggers need the record change to be committed or the FlowAPI call to be invoked with complete inputs — otherwise it won’t start.

 

If you want to call Flow Designer programmatically, best practice is to do it in an After Update BR (or a Scheduled Job).

 

 

Move your flow call into an After Update BR (or async logic) instead of Before.

 

And try this script:

(function executeRule(current, previous /*null when async*/) {
    if (current.install_status.changesTo('retired')) {
        try {
            gs.log("Inside BR Try");
            var flow = new sn_fd.FlowAPI();
            var inputs = {
                record_sys_id: current.sys_id.toString(),
                record_table: current.getTableName(),
                prev_status: previous.install_status.toString()
            };
            flow.startFlow('3D5628d3c683532210548acf...', inputs);
            gs.log("Flow triggered successfully for record: " + current.number);
        } catch (e) {
            gs.error("Error triggering Flow: " + e.message);
        }
    }
})(current, previous);

Hope it helps!

If this works, please mark it as helpful/accepted — it keeps me motivated and helps others find solutions.
Shashank Jain

Hello Shashank,

 

THanks for your reply.

I have 2 questions here.

1. the First thing is , even if the user changes the Status to Retired, I am not considering the change and moving back the status to it's current value. Because, only after the Approval is approved from the business owner, then I will change it to Retired.

 

2. Secondly, How to configure the inputs in the flow designer, with the inputs from the BR ?

 

 

 

Regards,

Lucky

Stefan Reichelt
Tera Guru
Tera Guru

Two questions:

- How do you make sure that the BR isn't triggered again once the Flow changes the status to retired after the appvoval?

- Why don't you simply trigger the Flow directly using the regulat Flow trigger instead of letting an extra BR do it?

 

And a hint: If you really need to trigger it from a BR (which I would only do if absolutely necessary), triggering a Subflow works better, at least from my experience.

Hello Stefan,

 

The thing here is, I don't want to make the Status to change to Retired directly, It has to change Post approval from business owner. Hence I have created before BR, and want to trigger flow designer for triggering approvals.

 

Now, I am stuck in flow designer how to configure the inputs that are presnt in BR.

 

 

Regards,

Lucky