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> 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...? If I only use a List 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 "Attempt to de-reference a null object" error. Any suggestions appreciated.
@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;
}