Call a Apex class from a Flow [ @InvocableMethod ]



Two options to call a Apex class from flow
 @InvocableMethod
 Process.Plugin interface.
I prefer Using @InvocableMethod which is much shorter and more straight forward to follow. It is also more efficient when dealing with multiple records.

Code:

global class lookUpAccountAnnotation {
   @InvocableMethod
   public static List<String> getCampaignIds(List<Campaign> campaignList) {
      List<Id> campaignIds = new List<Id>();
      List<Campaign> campaign= [SELECT Id FROM Campaign WHERE Name in :campaignList];
      for (Campaign c : campaign) {
         campaignIds .add(c.Id);
      }
      return campaignIds;
   }
}
Flow:

When you include  @InvocableMethod it would sit in apex Dropdown of palette.
You Need to drag and Drop it to the Flow and configure the inputs and Outputs



Instead Of Calling Apex from Flow. I would prefer Fast Create to insert multiple records. Below is the Link on How to use Fast Create

 https://salesforcesidekick.com/2015/08/24/how-to-use-a-fast-create/

P.S: Comment Below for any Clarification or help!!


Happy working!! :) :) 







Comments

Popular posts from this blog

Embed Special Characters in VF Page

Error: Compile Error: Illegal conversion from String to System.PageReference

Some Common Errors in the Visual flow