You need to sign in to do that
Don't have an account?
Haystack Certified
Bulkifying visual workflows called by triggers
I have been using code like this for calling Visual Workflows from a trigger.
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?
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?
BHinners
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.