You are using an older browser that might negatively affect how this site is displayed. Please update to a modern browser to have a better experience. Sorry for the inconvenience!

Bulkified Process in Process Builder Using Apex Class


By: Santhosh

Process Builder now supports bulkified process from Winter 16 release.  This article explains how Process Builder can be used to build bulkified transactions.

Invocable Method:

The Invocable method will allow an Apex method to be executed as an invocable action.

Apex Class:

Public class AutoConvertLeads

{

   @InvocableMethod

   public static void LeadAssign(List<Lead> LeadIds)

   {

           for(Lead currLead: LeadIds){

           

           Database.LeadConvert Leadconvert = new Database.LeadConvert();

           Leadconvert.setLeadId(currLead.Id);

           

           LeadStatus Leads= [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true ];

           Leadconvert.setConvertedStatus(Leads.MasterLabel);

           

           Database.LeadConvertResult Leadconverts = Database.convertLead(Leadconvert);

           System.assert(Leadconverts.isSuccess());

    }

  }

}

The steps involved in calling the Apex class that supports bulkified transactions in Process Builder.

Process Builder:

Step 1:

Click Setup → Create → Workflow & Approvals → Process Builder.

Art ps.png

Step 2:

Click the New button to create a new Process Builder process, and provide the process name and Description, and then click the Save button.

Selection_002.png

Art 2.png

Step 3:

Choose an object:

Art 3.png

Step 4:

Specify the entry criteria and click the Save button.

   Art 4.png

Step 5:

Select the “Action Type” as ‘Apex’.

Art 6.png

Step 6:

Select the “Apex Class” name and Set Apex Variables.

Art 10.png

Step 7:

Click “Ok” to activate the process builder.

activate Process.png

Step 8:

Click Lead tab → New button to create a Lead in Salesforce.

Lead Creating.png

Step 9:

While clicking the save button, the ‘Lead’ is converted to ‘Account’, ‘Contact, and ‘Opportunity’. For this article, we didn’t use any specific criteria to convert the Lead, but the business processes might require you to include certain criteria before converting the Lead.

Selection_001.png

Account.png

Limitations of Process Builder :

  1. Using Data loader, we can convert only up to 100 leads.

  2. SOQL supports 100 per-transaction limit.

Summary:

Beginning Winter 16, we can use Process Builder for bulkified transactions using Apex Classes.