7

I have a simple Platform Event defined in several of our orgs (sandboxes), but in one of them, they just refuse to work.

As a test, I set up an Apex trigger subscriber to the event, made sure it's active, put a bunch of debugs in there so that I know when it gets called.

I can publish the event in Developer Console anonymous Apex and get no errors, but the Apex trigger subscriber never fires (I have another subscriber which is a Lightning Component using CometD and it doesn't received them either).

I can run the exact same test in other orgs without problems, but in this one org, it looks like Platform Events and/or the Event Bus just doesn't work. There are no errors, it just doesn't look like events are getting published.

The event is in deployed status, the trigger is active, I've double and triple checked everything I can think of, but it just doesn't work.

Has anybody run into this before? Any ideas on how to kickstart events working in this one org?

Thanks!

4
  • What API Version are you using? Make sure every class you use is updated to the most recent available version.
    – Adrian Larson
    Commented May 31, 2018 at 23:38
  • Good idea, thanks. I'll check the API versions tomorrow and report findings. Thanks! Commented Jun 1, 2018 at 5:09
  • I couldn't find an API version on the Platform Event object itself, but the API on the trigger subscriber is 43.0. I also created a new Platform Event with no custom fields, just a plain new object and made sure it was deployed. Also created a trigger subscriber to go with it and made sure it was active (it has some debug statements in it). Still doesn't work. When I use anonymous Apex in the Developer Console to create a new event and publish it, the trigger doesn't run - no new log entries, and nothing in the UI to indicate the subscriber/trigger has processed any events. Strange!!!! Commented Jun 1, 2018 at 16:30
  • Does the trigger call any classes? Check the version on those as well.
    – Adrian Larson
    Commented Jun 1, 2018 at 17:00

4 Answers 4

6

Deleting the Platform Event and recreating it seems to have fixed it.

I recreated it with exactly the same object name, and fields. Created another test trigger subscriber for it, and now it works.

Don't know what went wrong, but it appears this event and/or its event bus got broken somehow.

Very strange, but at least its working now.

1
  • See my post for an explanaition. Recreating with an admin profile usually grants permissions to the object (something, that is not automatically done if the object was deployed) Commented Jul 22, 2021 at 11:55
3

I have come across this issue recently, and what we could see was the following:

  1. When trying to publish an event, the logs told us that it had been published correctly, but the subscribers of the event were not triggered
  2. Posting the event from another source worked fine. That is, if we published it from a trigger or elsewhere

In the end we realized that we were sending more characters to one of the fields of the platform event than what the field had defined, only that at the time of publishing it, it did not give us an error.

Finally, it is important that when publishing an event, it is validated that the fields that we are filling are within the parameters defined for each field.

1
  • 2
    I had been researching this exact problem for days now and your answer was the one that solved it. This needs the big upvote.
    – GeorgeA
    Commented Oct 19, 2022 at 17:05
2

Platform Events require permissions. If you create them with the same admin credentials you use to authenticate the CometD subscriber, you are usually automatically given the permissions. If you deploy them (in a source driven process), your profile does not necessarily have access to them.

Navigate to Profile (or Permission Sets) > Object Settings > Platform Event Label and make sure, the user that listens to this events has at least Read permission.

Standard User Profile Object Settings for Platform Event

1
  • Thanks for this! The screenshot helped a lot as I fumbled around trying to find it in our setup
    – Pat
    Commented Jul 23 at 17:50
1

I had the same issue. By upgrading the API version(from 40 to 43) for the Platform Event trigger seems to be working for my case. If your version is 43, then just update from 43 to 42 then update it back again. Because by updating the API version, from 43 to 42 then update it will do the thing. It is not the API version triggered this issue. I think by changing API version is a way to reactivate the Platform Event

4
  • 2
    The original poster states in comments that their trigger is already on API Version 43.
    – David Reed
    Commented Aug 13, 2018 at 2:33
  • @DavidReed, by updating the API version, from 43 to 42 then update it will do the thing. It is not the API version triggered this issue. I think by changing API version is a way to reactivate the Platform Event.
    – Alvin Zhou
    Commented Aug 13, 2018 at 5:52
  • I'd suggest editing your answer to clarify that for others who might stumble across this question in the future.
    – David Reed
    Commented Aug 13, 2018 at 11:15
  • This worked. I had my trigger it in the latest current API version (v48), downgraded it to API 47 and then back to 48 and now my events are working! Man, I wished i googled sooner :( Commented Apr 17, 2020 at 22:49

You must log in to answer this question.

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