I am invoking an apex class in my flow, which returns List<List< String>> back to the main flow. The flow surprisingly doesn't let me store the returned value in a collection variable. Now I want to loop over the inner list of strings and display each value from the list as a line item on a screen, however, I do not have a collection variable to loop over. Please see the attached screenshots. Any help is much appreciated.

enter image description here enter image description here

  • Seems like you may be having an XY Problem. Why are you returning a List<List<String>> in the first place?
    – Adrian Larson
    Dec 2, 2021 at 14:49
  • 3
    @AdrianLarson Because InvocableMethods are bulkified, thus to return a collection, you need a list of list of some type.
    – sfdcfox
    Dec 2, 2021 at 14:55

1 Answer 1


You've chosen the wrong combination of settings in your Apex Action element. You must either (a) create a new Collection from the Resource Manager, check the Manually assign variables, and then assign that Collection in the box below (that reads output in your first screen shot), or (b) uncheck the Manually assign variables checkbox, which will provide you with an automatically created collection called Text Collection from <Apex Action Name>. By using the Manually assign variables checkbox and leaving output blank, you're effectively discarding the results of the call.

When you uncheck Manually Assign Variables, you get the following Collection automatically:

Automatic Collection

You can then use this directly in a loop:

enter image description here

When you check the box, you must create your own:

Create New Resource

Assigning Output

Using in a Loop

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .