You need to sign in to do that
Don't have an account?
EmilyCobb
Invocable Method returning List of List
I'm working with cloud flow designer and having some issues with the Apex class callout. I know I will need to return a List<List<CustomSobject>> from the invocable method in order to process the collection. But I am stuck overcomplicating the code in order to get what I would normally use a List for into the right format to return. I probably need an additional for loop but am not sure of the format. If I only return a List<CustomSobject> the Flow will not be able to process it as a collection returning multiple records. Below is my method, this current version compiles but the flow will throw an "List index out of bounds" error. Nor is it correct, as I want all the elements returned not just the first. Thanks in advance.
@InvocableMethod(label = 'Services Available') public static List<List<Create_Product__c>> getServices(List<Address__c> addressInput){ //created to hold return list of lists List<List<Create_Product__c>> wrapper = new List<List<Create_Product__c>>(); //The data set to be returned List<Create_Product__c> productsAvailable = [SELECT Product_Code__c, Starting_Price__c FROM Create_Product__c]; for (Create_Product__c products: productsAvailable ){ List<Create_Product__c> responseList = new List<Create_Product__c>(); responseList[0].Product_Code__c = products.Product_Code__c; responseList[0].Starting_Price__c = products.Starting_Price__c; wrapper.add(responseList); } return wrapper; }
I don't know in what structure you need List<List<Create_Product__c>>, but still I can provide you two correct approaches.
First Correct approach:
Second correct approach:
Thanks
Gulshan Raj
All Answers
I don't know in what structure you need List<List<Create_Product__c>>, but still I can provide you two correct approaches.
First Correct approach:
Second correct approach:
Thanks
Gulshan Raj