Call Apex Through Process Builder

So today I will post how to call apex Class through Process Builder. Sometimes there is a requirement when we need to apex class through Process Builder.

Apex Class :

Public class InvokeClassThroughProcessbuilder
{
    @InvocableMethod(label='Get Lead Name')
    Public static void LeadUpdatefromProcessBuilder(List <ID> LeadIds ){
    
    Set<Id> leadId= new Set<Id>();
    leadId.addAll(LeadIds);
    List< Lead > leadtoUpddate = new List< Lead >();
    For (Lead objLead : [Select id,Status,Primary__c FROM LEAD WHERE ID IN : leadId])
    {
        objLead.Primary__c = 'Yes';
        leadtoUpddate.add(objLead);
    }
    if(!leadtoUpddate.isEmpty())
    {
        update leadtoUpddate;
    }
    
    }
    
}

Screenshot For Process builder :

Output :

Hope this helps 🙂

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s