Posts

Apex-Defined Types in Flow in Plain English

 It's pretty opaque how Salesforce handles Invocables when using an Apex-defined type. In my use case I am trying to create a generic utility that returns a bunch of stuff that you can't get in Flow. Achieving this is pretty unforgiving and I found it very confusing, so here's my attempt to demonstrate it in plain English. Part 1: The Response You need a standalone Class for the Response. In this case, I populate the values in the constructor. Note that the variables are both @AuraEnabled and @InvocableVariable. The @AuraEnabled allows the Class to be recognized as an Apex-defined type in the Flow.     Part 2: The Invocable Method Your Invocable method takes an input, in our case a List<FlowUtilityRequest>. You will receive a list with a FlowUtilityRequest for each record your Flow is processing. So if the Flow runs with 100 records, you'll get a list with 100 copies of the Request. The Response is sent in a List<List<FlowUtilityResponse>>. The size o...