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.
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.
Step 3:
Choose an object:
Step 4:
Specify the entry criteria and click the Save button.
Step 5:
Select the “Action Type” as ‘Apex’.
Step 6:
Select the “Apex Class” name and Set Apex Variables.
Step 7:
Click “Ok” to activate the process builder.
Step 8:
Click Lead tab → New button to create a Lead in Salesforce.
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.
Limitations of Process Builder :
- Using Data loader, we can convert only up to 100 leads.
- SOQL supports 100 per-transaction limit.
Summary:
Beginning Winter 16, we can use Process Builder for bulkified transactions using Apex Classes.