I'm trying to move my apex triggers over to flows and I've got an issue - I've got a trigger that is making one callout per multiple updates depending on various conditions.
This is easy to do in a trigger, since the system batching of records is explicit in the Trigger.new context variable, and you can just make a callout, then directly reference the Trigger.new to do whatever you want with the records.
Example:
trigger ExampleUpdateTrigger on Example__c (after insert, after update) {
if(conditionx){
CalloutHandler.DoCallout();
}
RecordHandler.HandleRecords(Trigger.new);
}
However on my trigger flow, I'm creating a platform event to allow the external services callout, but the system ends up implicitly batching the platform events in the flow - so if I've got like 6 records created, 6 platform events get made, it will do 6 callouts. Is there any way to force platform event flow to just do something once?
Also, it seems like something a bit funny is going on with conditions within the platform event flow - if in pe flow one, I attempt to create a flag on a record (to prevent callout) which is then looked up by subsequent flows, it doesn't seem to work. It seems like every flow iteration is looking up flag = good ---> every flow is updating flag ----> every flow makes callout.