function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Haystack CertifiedHaystack Certified 

Bulkifying visual workflows called by triggers

I have been using code like this for calling Visual Workflows from a trigger.
 
public static void start(List<Account> TriggerNew) {
        Map<String, Object> myMap = new Map<String, Object>();
        
        for(Account ac: TriggerNew) {
            myMap.put('txtAccountRecordID', String.valueOf(ac.Id));
            Flow.Interview.Set_Account_Zero_Tax_Rate myFlow = new Flow.Interview.Set_Account_Zero_Tax_Rate(myMap);
            myFlow.start();
        }
    }

The issue is that it is not quite bulkified because the flow is being called individually for each record.  Is there a way to send the entire trigger.new list to the flow?
BHinnersBHinners
Now that Visual Workflow supports collections, you should be able to rewrite your Flow to deal with multiple IDs at once, which would allow you to pass multiple records at once.  You'll need to rewrite both your flow and your trigger to use collections rather than single records.