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 🙂