Wait for Field Value change in Flow Designer

alexander_winkl
Tera Expert

Can flow designer detect a change in field value for the purposes of restarting the entire flow? We have a requirement that any time the Due Date value changes on our record, the flow should restart so that it can re-evaluate which state it should be in based on a script. I currently have the Flow designed to trigger any time a record is created or updated, and the Due Date changes and isn't empty. My fear is that the Flow will create a new instance of Flow each time the record is updated, without cancelling the old flow.

1 ACCEPTED SOLUTION

Jon23
Mega Sage

hi @alexander.winkley@accenturefederal 

One approach is to have your main flow to trigger 'Only if not currently running'.

Then have a before business rule to trigger when the 'Due Date' changes. The BR script will cancel the existing workflow(s).

Your main workflow will then trigger again as it is not currently running:

example:

before business rule calls a flow designer action on Due Date change (code grabbed from flow designer code snippet):

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

    try {
        var inputs = {};
        inputs['sourcerecord'] = current; // String 

        // Start Asynchronously: Uncomment to run in background. Code snippet will not have access to outputs.
        var result = sn_fd.FlowAPI.getRunner().action('global.cancel_flow').inForeground().withInputs(inputs).run();
        var outputs = result.getOutputs();

        // Current action has no outputs defined.		
    } catch (ex) {
        var message = ex.getMessage();
        gs.error(message);
    }

})(current, previous);

Flow designer action looks up records on the sys_flow_context table that matches incident record:

find_real_file.png

For each record run the script to cancel:

find_real_file.png

View solution in original post

9 REPLIES 9

Kim Sullivan
Tera Guru

thanks but I ended up figuring it out

Can you describe your soultion?

I have some of the same issues with waiting for a condition before continuing the flow

 

I ended up creating a subflow to look up all the catalog tasks on that RITM.  Then did a wait for condition on them all to be State Is Closed Complete or Skipped or Incomplete.  Then finish the subflow.  That would then move to my next condition and review all the tasks one last time.  Its ugly, but works for me.

Hey @Kim Sullivan do you recall what your final approach to this was? I'm facing a similar situation currently.

I ended up creating a subflow to look up all the catalog tasks on that RITM.  Then did a wait for condition on them all to be State Is Closed Complete or Skipped or Incomplete.