I created a one-time use flow for migration purposes. It looks up all the records to update, and calls a subflow to update each one. The subflow runs 8 or 10 queries and then updates one record.
Unfortunately, the migration flow dies on the 10th record with a Too Many SOQL Queries error. I expected each subflow to execute separately but instead all of the queries of all subflows have been counted towards the total! This is really silly.
It seems that the subflow does not get bulkified. Is there a way to do mass update records from a flow calling a subflow?
Otherwise how can I create a batch process or otherwise call the record update flow for all records? The two options I can imagine now are: 1. call flow from developer console anonymous apex window 2. create a process to call the flow on record update, and force the process to run with data loader or anonymous apex
I tried to run it from an anonymous apex window in developer console but again, my DML fault email tells me "Error Occurred: Too many SOQL queries: 101". FYI this was the code:
String theFlowAPIName ='Meeting_Note_mail_merge_data_field_update_Call_from_Controller';
String q = 'select id from Contact_History__c order by id';
List <Contact_History__c> recs = Database.query(q); // Get list of ids
for (Contact_History__c o : recs) {
// set flow input parameters
Map<String, Object> params = new Map<String, Object>();
params.put('varMeetingNoteId', o.id);
// In that component, start the flow to refresh the mail merge data field
Flow.Interview flow = Flow.Interview.createInterview(theFlowAPIName, params);
flow.start();
}
Here is a screenshot of the migration flow. The subflow it calls is the same one that is normally called from the controller.