1

This is my first time posting in StackExchange, and my first real attempt to put together some code.

I am attempting to query CampaignMembers from the data base after passing a CampaignID to the class from a Flow. Once the Apex executes I would like to return a collection of CampaignMembers to the Flow including Id,ContactId,CampaignId.

I understand a list of lists may be required to achieve my desired outcome, but I'm unable to hack it together.

I've copied my code below.

global with sharing class ReturnCampaignMembers {

    @InvocableMethod
    public static List<Results> GetStatus (List<Requests> requests)
       {
           ID v_camId = '7015A000001qWPcQAM';
           List<CampaignMember> rc_CM = [SELECT Id, ContactId, Contact.AccountId, CampaignId 
                 FROM CampaignMember WHERE Contact.Account.UpsellOpportunity__c='Yes' 
                 AND Contact.Account.Rating='High' AND CampaignId = : v_camId];

        Results curResult = new Results();

       List<Results> resultsList = new List<results>();          
        resultsList.add(curResult);
        return resultsList;
       }
        global class Results {
            @InvocableVariable
            global ID campaignmemberId;

            @InvocableVariable
            global ID campaignId;

            @InvocableVariable
            global ID contactId;

        }
        global class Requests {
            @InvocableVariable
            global String v_camId;  
        }     
}
  • You have to return list<list<Result>> from invocable to get a collection in flow. – Ashish Sharma May 8 '19 at 6:18
  • Could you show me what you mean? I understand the concept, but can't seem to get it to work. – J. Steadman May 8 '19 at 11:29
0

You need to return List> to get collection in flow. Please follow the link to understand more: https://success.salesforce.com/answers?id=9063A000000pOpyQAE

Your Answer

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.