3

I have a flow which subscribes to a platform Event. This flow consumes the event and inserts a record. My test class is:

Test.startTest();
            
Database.SaveResult result = EventBus.publish(testEvent);
System.assertEquals(true, result.isSuccess());  
Test.getEventBus().deliver();

Test.stopTest();

It looks like only Apex triggers are running after the Test.getEventBus().deliver() statement while Flow is not at all getting triggered. I thoroughly checked the logs and there is no logs of the Flow running. I checked that the Flow is Active. Salesforce explicitly says that flows are triggered from apex test class here: https://developer.salesforce.com/docs/atlas.en-us.platform_events.meta/platform_events/platform_events_test_events.htm

5
  • What API version is your test class using? The documentation mentions that the test class needs to be v43.0 or newer for processes/flows to be run.
    – Derek F
    Jul 21, 2021 at 15:41
  • My Test class is at API version: v52.0 Jul 21, 2021 at 16:07
  • I have checked that this works for both standard and custom events and with both publish after commit and publish immediate . The only requirement seems to be that the flow must be active. Can you confirm that flow is active? Jul 28, 2021 at 11:49
  • Yes. The flow is active. The event is setup as publish immediately. This seems to be the case for all the platform event flows in my org. Any other suggestion? Aug 5, 2021 at 17:40
  • This will need checking your org. Please consider logging a case with salesforce support for further investigation on this. Aug 11, 2021 at 8:34

1 Answer 1

0

Use this query to check the flow is subscribed to the platform event.

SELECT Name, Position, Retries, LastError FROM EventBusSubscriber

If its not listed, save a new version of the flow. I ran into this on a newly created sandbox

You must log in to answer this question.

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