0

I have a flow setup to pass in a collection of opportunities to process and send back a collection of opportunities. In the flow I have queried the opps, assigned them to a record collection variable and check the "Available for Output" option. However when I used the apex action in the flow, there is no option to pass the collection variable to the apex class. I am trying to understaynd why I can't pass in my record collection variable.

enter image description here

public class FindOpportunities {
@InvocableMethod(label='Find Opportunities')
public static List<List<Opportunity>> findOpps(List<Opportunity> oppList) {
    List<Opportunity> invalidOpps = new List<Opportunity>();
    
    for (Opportunity opp : oppList) {
        if (opp.AccountId != null && opp.Account.Type != 'Customer' && opp.Account.Account_Status__c != 'Active') {
            invalidOpps.add(opp);
        }
    }
    
    List<List<Opportunity>> result = new List<List<Opportunity>>();
    result.add(invalidOpps);
    
    return result;
}

}

New contributor
Greg Watkins is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
1
  • 3
    Can you try keeping input parameter as List<List<Opportunity>> oppList and see if helps? Related
    – Swetha
    Mar 16 at 14:57

1 Answer 1

0

As you want to pass record collection variable to apex class, you need to use List<List<sObject>> as flows are bulkified and this is expected behavior.

Found this article having more information enter image description here

Your Answer

Greg Watkins is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.