Bulkified Process in Process Builder Using Apex Class

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

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.

About MST

At MST Solutions our cornerstone is to adapt, engage and create solutions which guarantee the success of our clients. The talent of our team and experiences in varied business verticals gives us an advantage over other competitors.

Recent Articles

Session Based Permission Sets

A Permission Set is a collection of settings and permissions that give access to users to various tools and functions. The settings and permissions in Permission Sets are additionally found in profiles, but permission sets broaden users’ functional access without altering their profiles.

Read Article »

Work with us.

Our people aren’t just employees, they are key to the success of our business. We recognize the strengths of each individual and allow them time and resources to further develop those skills, crafting a culture of leaders who are passionate about where they are going within our organization.