Basic Invocables in Flows

Tzhe’ela Trooper
3 min readJul 5, 2022

Creating an Invocable method, to be called from a flow and passing a List<String> instead of records.

Step 1: Write an invocable metod and deploy to org

Step 2: Open flow explorer, and choose the trigger type you are after

Step 3: Create a variable to pass to the invocable action
I created a formula text variable to match future task I had in mind, but a singular text variable will work as well.

Step 4: Add an action to the flow - Select the action you deployed based on the category you’ve specified

Step 5: Populate the action params
Note that this is a singular variable, not a collection.

Step 6: Save flow + activate debug logs + debug the flow

Congrats - You created an Invocable method that takes a List<String> and was able to return your results to the flow.

For this demo, I’ll be working with a return of 3 String values to the flow our List<List<String>>, and would like to capture each in a separate loop variable for later access.

A more advanced version would be to create a decorator class (a.k.a Apex-object) so you could dot notate the different variables. For ex: ApexObject.firstVariable.

Step 7: Create variable to hold the values returned by the Invocable method

For this demo I created 3 variables, to hold the 3 values I’m passing from Apex back to the flow.

Step 8: Create an iterator and a for-loop. I set the default value of the iterator to 1 for simplisity.

Step 9: Configure a decision and some assingment elements to match

Step 10: Don’t forget to up the iterator

Step 11: Debug your flow

Again, a better-cleaner way will involve an Apex-Object so you won’t need to use the loop. But I wanted to capture this option here for personal future reference.

All done !

--

--