Skip to main content

Hi!  

In Flow Builder when we 

Deactivate the flow, sometimes we are asked whether we want to:

  1. Deactivate and complete work, or
  2. Deactivate and cancel work.

And for some flows this question is not asked. But I still haven't figured out exactly when this happens and it could be that there are similar scenarios where a question is asked. 

Flow Deactivation Behaviour

 

My code is trying to imitate that behavior.  

  

 To deactivate the flow I currently use the tooling API to set the 

activeVersionNumber of a flow definition to 0. And this deactivates the flow:

HttpRequest req = new HttpRequest();req.setEndpoint('callout:' + MY_NAMED_CREDENTIA+ '/services/data/v61.0/tooling/sobjects/FlowDefinition/' + flowDefId);req.setMethod('PATCH');req.setHeader('Content-Type', 'application/json; charset=utf-8');req.setBody('{"Metadata":{"activeVersionNumber":0}}');req.setTimeout(60000);

 

I am looking at the documentation of FlowRecord and FlowRecordVersion

. But I still haven't been able to conclude what the lifecycle is. 

 

The 

ProgressStatus 

field in specific is interesting. The flow version can be in statuses like "InProgress", "Finishing", "PreparingData", etc. 

 

In 

FlowRecordVersion 

we have fields for the number of Entries, Exists, Errors and Stopped. 

 

If you want to code the deactivation, how do you make sure that the flow still has some work in progress (e.g., contacts in a wait activity, a path scheduled in the future), or not? Salesforce knows when to show that dialog. So, why can't I? 

  

 @Salesforce Flow Automation

#Flow

4 respuestas
0/9000