Tuesday, January 31, 2017

Which interface needs to be implemented in Apex to be used in Flow ?

We can execute apex as well using flow by annotating it with “@InvocableMethod” and marking method as static. However this method only takes one parameter of type list. If we want to send multiple parameters, then simplest way is to create comma separated list of argument and pass it. In this method, we can break it and use according. Below is sample code.
Global class Flow_UpdateAccountField {    
    @InvocableMethod
    public static void performUpdate(List<String> lstCSV){
        List<String> recIds = lstCSV[0].split(',');
        //0 - AccId, 1-field1__c
  Account acc = new Account(Id=recIds[0], field1__c=recIds[1]);
  update acc;        
    } 

}

No comments:

Post a Comment