1

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.

1 Answer 1

1

you will have to create an apex invocable class that will get as an input the flow interview id and will output a single interview id. You should use a static var in your invocable class that is set only once and use it for the output

public static string interviewId;

loop on invocable input list if ( interviewId == null) interviewId = listItem end loop

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .