Manage the execution and interfacing of runtime resolved Flows in Apex
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
force-app/main/default
.execanon
.forceignore
.gitignore
LICENSE
README.md
sfdx-project.json

README.md

FlowProcess

Image

Manage the execution and interfacing of runtime resolved Flows in Apex

Deploy

The FlowProcess class wraps the Apex Flow API and allows you to manage the execution and interfacing of runtime resolved flows in Apex. It focuses on providing support for declaring inputs and outputs as well as integrating with Custom Metadata types as a means to allow admins to control which flows are invoked

List<Account> accounts = (List<Account>)
    new FlowProcess().
        named(dynamicFlowName).
        with('SomeRecords', [select Name, Id from Account]).
        returning('FilteredAccounts'));

You can also reference a Custom Metadata Type to allow Admins to configure the Flow to run

List<Account> accounts = (List<Account>)
    new FlowProcess().
        named('FilterAccounts',
           MyAppFlows__mdt.SObjectType,
           MyAppFlows__mdt.FlowName__c).
        with('SomeRecords', [select Name, Id from Account]).
        returning('FilteredAccounts'));

You can also mock Flow invocations during tests.

// Given 
FlowProcessRunner mockRunner = 
    (FlowProcessRunner) Test.createStub(FlowProcessRunner.class, new RunnerMock());          
FlowProcess.setMock(mockRunner);
        
// When
List<Account> accounts = (List<Account>) 
    new FlowProcess().named('GetSomeRecords').returning('Records');
            
// Then
System.assertEquals(1, accounts.size());
System.assertEquals('MyAccount', accounts[0].Name);

You can read more about this library and Flows in general in this blog.