Thursday 14 May 2015

How to call apex class from process builder?

As we all know it is not possible to invoke apex class from work flow,for that purpose sfdc lunched new functionality called process builder.

Please go through this link. In my previous post i have explained about creation of process builder and updating a field through process builder.

Now this is post is all about calling an apex class from process builder.

public class DeleteBrassCaseUtil{

  @InvocableMethod(label='Get Brass Cases Names' description='Returns the list of Brass Cases corresponding to the specified Brass Cases IDs.')
  public static void deleteBrassCase(List<Id> BrassCaseIds)
    {
        List<BRASS_Case__c> brassCases =[SELECT Id,Is_Org_Case_Created__c FROM BRASS_Case__c WHERE Is_Org_Case_Created__c =true AND id IN :BrassCaseIds];
 
        delete brassCases;
    }
}

The annotation "@InvocableMethod" defines this method can be invoked from process builder. This class will delete some custom object records based on meeting criteria.

Below is the process builder.






3 comments:

Unknown said...

Hi,

Request you to add some clear screenshots of the process builder.

Thanks
Dilowar Hussain
Phone: +918095188996
Bangalore

Asish Kumar Behera said...

HI Dilwar,

I am sorry, what exactly looking for in the screenshot. for me it looks ok.

Thanks,
Asish

Nish said...

Hey Asish,

This is really helpful to get a basic understanding of how to invoke an apex class from Process builder. Thank you !!

Nishanth