Questions tagged [platform-event]
Platform events are part of Salesforce’s enterprise messaging platform. The platform provides an event-driven messaging architecture to enable apps to communicate inside and outside of Salesforce. Custom data in your events are stored in custom fields that you define.
449
questions
31
votes
1
answer
21k
views
How do I see debug logs for Platform Event triggers in Salesforce?
As per Enterprise Messaging Platform in the Summer '17 release notes and First Impressions with Platform Events and the Salesforce Enterprise Messaging Platform I created a simple Platform Event with ...
26
votes
2
answers
8k
views
Apex Rest Vs Platform Events for Inbound SF integration which one to choose?
Am in a design dilemma in choosing which would be the best approach in the Integration which we would be doing shortly.
To give a brief idea, the external system wants to send JSON data to SF. We ...
22
votes
1
answer
993
views
Why use Platform Events in standalone native apps?
In Summer '17 Salesforce released Platform Events - a native messaging system accessible via Apex and several APIs.
I assume the main use case for such a feature is to allow integration of Salesforce ...
22
votes
3
answers
813
views
Is it possible for a test class to create data outside of the test execution context?
If you have a test set to SeeAllData=true, and you publish a platform event that has a trigger that inserts a record, will that data actually be created in the org?
trigger PlatformEvent on ...
20
votes
3
answers
21k
views
What is the difference between the Streaming API PushTopic, Generic Streaming and Platform Events
Salesforce offers two variants of the Streaming API - PushTopic and Generic.
In Summer '17 (v40.0) Platform Events are now also Generally Available (GA).
How do they differ and why would you use one ...
18
votes
1
answer
4k
views
Do Platform Event Triggers process synchronously? Do they get a fresh set of limits?
I'm intrigued by Platform Events, but I have a few questions about how they operate:
Are the subscription triggers processed synchronously or asynchronously?
The developer guide makes it clear that ...
17
votes
1
answer
8k
views
How do I change the running user of a platform event trigger handler?
Our org needed to change the running user of a platform event to support automated chatter posts, since the Automated Process user can't access the ConnectApi. I just spent several hours piecing ...
15
votes
4
answers
20k
views
Test that a Platform Event was published?
We have custom object CustomObject__c and platform event Platform_Event__e.
Whenever any of CustomObject__c records are modified, platform event should be published. We need to write test class to ...
15
votes
1
answer
5k
views
Testing BatchApexErrorEvent trigger
I have a batch class which implements the Database.RaisesPlatformEvents interface. This interface has recently been introduced and helps log unexpected exceptions: https://developer.salesforce.com/...
14
votes
5
answers
4k
views
Any Platform Event Library or Best Practices out there?
I'm coming to a point where my software does to many things at the same time, so I decided to switch to Platform Events to decouple everything. I don't handle external events, I'm only planning to use ...
14
votes
2
answers
8k
views
What causes platform events to fail to be published and should I cater for failed platform event creations?
After examining docmentation I have began to create a platform event from Apex, but I have 3 unanswered questions when it comes to the creation of platform events concerning unsuccessfull publishing ...
14
votes
1
answer
3k
views
Documentation Incorrect? Is it possible to cover/deploy triggers on Platform Events?
I am about to roll out some code which uses Platform Events, and hitting a troublesome roadblock in testing. Is calling Test.stopTest() supposed to cause subscriber triggers to fire and subsequently ...
13
votes
1
answer
4k
views
Sandbox Trigger that subscribes to platform event never executes
Use case:
PROD has a working Platform Event Foo__e with corresponding subscriber trigger FooTrigger as follows:
trigger FooTrigger on Foo__e (after insert) {
.. do work
}
When a new sandbox (cs50)...
13
votes
0
answers
419
views
Is there a way to force a Platform Event Trigger to honor the PlatformEventSubscriberConfig in unit tests?
I'm attempting to move an integration away from using Custom SObjects and to using Platform Events out of a concern for storage space (and also so our eventual automation of this integration won't ...
12
votes
3
answers
2k
views
Platform Event Apex trigger limits exception - where does it go?
If one publishes a Platform Event, the consuming trigger executes as Automated Process user. If that consuming trigger exceeds CPU limits, no notification is sent to the developer(s).
Even though ...
12
votes
1
answer
3k
views
Cannot subscribe to platform events using cometd
I am trying to subscribe to a platform event using cometd. I have asserted that the event is getting published just fine but its subscribing that is an issue.
I have placed console logs in the cometd....
11
votes
3
answers
4k
views
How do I successfully Deploy a Configuration Component for a Platform-Event Trigger to Override the Automated Process User?
I am trying to override the Automated Process user with another user for a platform event.
This Salesforce documentation covers it:
Configure the User and Batch Size for Your Platform Event Trigger
...
11
votes
0
answers
1k
views
How to convert Standard Volume Event into High Volume Platform Events?
With Spring 19, High Volume platform events are generally available. Now I want to convert my existing standard volume event into a high volume event.
I tried editing the event object in Setup, it ...
10
votes
5
answers
26k
views
How to monitor Platform Events consumption?
According to SU17 release notes there are the following Daily/Hourly limits for Platform events:
Maximum number of events published per hour
Maximum number of events delivered to CometD clients ...
10
votes
1
answer
3k
views
How to determine Platform Event Size in Apex to ensure to be within < 1 MB
The documentation on Platform event states:
The maximum event message size that you can publish is 1 MB.
Is there a native and reliable way in Apex to check whether the Platform Event I am about ...
10
votes
2
answers
5k
views
Unable to unit test code that publishes platform events
I keep getting a System.UnexpectedException whenever I run unit tests for code that publishes Platform Events. As soon as I call Test.stopTest(), the test fails with System.UnexpectedException: Error ...
10
votes
2
answers
4k
views
Logging frameworks that use Platform Events - what is the full list?
I've found these two excellent projects:
Andrew Fawcett's Advanced Logging with Platform Events
Robert Sösemann's Apex Unified Logging
that use Platform Events for logging and include a client to ...
10
votes
2
answers
13k
views
403::Organization total events daily limit exceeded
I'm trying to connect a cometd client to stream platform events, however, I'm getting an error that says I've exceeded my "total events daily limit".
{"clientId":"1xj1529zd8mx3ol01sl8hlzm5ewwj","...
10
votes
0
answers
919
views
Salesforce doesn't merge fields on email sent in platform event context
I have a process that runs every day in the morning. It is a scheduled class that publishes a platform event. When this event is run by the system, it collects some records and sends emails to some ...
9
votes
2
answers
4k
views
Will Change Data Capture eventually replace PushTopics/Streaming API?
I need to notify an external system component about changes in Salesforce data. I am confused by the fact that there exist two seemingly competing solutions in Salesforce for that. Both look very ...
9
votes
2
answers
3k
views
Does Messaging.SendEmail() not work in a Platform Event trigger context?
I can't figure out why an email isn't being sent. I've got a Platform Event trigger which ultimately is supposed to send an email. Most of the code isn't directly relevant, but here's the surrounding ...
9
votes
1
answer
583
views
Developer Console query on EventBusSubscriber returns only 1 row
This is too weird and just started happening within the last few days
Execute this query in DC (V43 or V44)
SELECT Id,LastError,Name,Position,Retries,Status,Tip FROM EventBusSubscriber
In DC
Only ...
9
votes
2
answers
1k
views
How can I scale Platform Events to actually be useful?
I have an LWC app I'm building with approximately 200 users, expected to grow to 400 over the next few years, so mid-size as far as Salesforce customers goes, I assume. We need the client side to get ...
9
votes
1
answer
2k
views
Which timezone are the platform events run with?
What does Salesforce use as the system time when running those jobs? The current system time (UTC)?
My context is that I have a job that is run every 30 minutes and it executes a task for some of my ...
8
votes
6
answers
8k
views
Can you call a webservice from a Platform Event Trigger?
For webservice callouts, I assume the same rules apply, but I just wanted to double check. I haven't found any information about Platform Events and Webservices. I assume I would just make it a @...
8
votes
2
answers
2k
views
empApi with Lightning Web Components?
I have an LWC in which I want to use EMP API. Docs say that's only currently available in Aura. Do I have to wrap my entire LWC in aura in order to add the EMP API, or can I create a utility aura ...
8
votes
2
answers
6k
views
How to clear/delete published Platform event from EventBus after sometime?
I'm publishing Platform Events using APEX Code
EventBus.publish method and consuming the events in backend Java app using EventListener.
Problem
All the published events remains in EventBus and ...
8
votes
2
answers
3k
views
Do Apex Transaction have a unique Id (like Batch Ids)?
I am working on a Platform Event based Logging Framework (based on the ideas of Andrew Fawcett's Dreamforce session).
I want to visually group Log entries of the same transaction or batch.
Batch ...
8
votes
2
answers
813
views
Reliable Detection of an Automated Process User
Because User Mode database operations don't work for the Automated Process User, I need to litter my code with checks to see if the current user is such a user.
I've previously got an automated ...
8
votes
1
answer
2k
views
Platform Event - lightning:empApi
I am using platform event and subscribing them in a lightning component. When i use my component as standalone lightning app or use it on lightning record page, the components subscribe well to the ...
8
votes
2
answers
3k
views
Critical Update: Require User Access to Apex Classes Invoked by Flow when running user = Automated Process
Given
Critical Update Require User Access to Apex Classes Invoked by Flow is activated
Apex trigger that subscribes to a Platform Event
Trigger logic does DML
Process Builder executes and makes ...
8
votes
2
answers
5k
views
Publish and/or subscribe to Platform Events between separate Orgs?
Does anyone have experience using Platform Events between separate orgs? I'm having trouble finding documentation or mention that something like this is possible. Basically I'd like to define a set of ...
8
votes
1
answer
506
views
New Apex Metadata API - displaying results on Visualforce page
So Summer 17 brings the new Apex Metadata API. What I am trying to do is start a deployment from a Visualforce page, and then display the results on the page once the deployment has completed.
Since ...
7
votes
2
answers
6k
views
How to publish/consume bulkified Platform Events
Use case:
External system wants to publish Platform Events to Salesforce.
Salesforce wants to consume the Platform Events in a bulkified manner
The Platform Events doc offers this REST call:
/...
7
votes
4
answers
15k
views
Platform Events not working in one of our orgs
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 ...
7
votes
3
answers
3k
views
How to subscribe to events from LWC embedded in Visualforce
I have an LWC which subscribes and display a custom Platform Event
import { LightningElement } from 'lwc';
import { subscribe, unsubscribe, onError } from 'lightning/empApi';
export default class ...
7
votes
1
answer
6k
views
Change Data Capture vs Platform Events vs Replication API vs Streaming API vs Batch Data Synchronization [closed]
I have a requirement to sync Salesforce data from 2 objects to Datawarehouse and insert/update data from Datawarehouse to Salesforce.We want this data sync to be realtime for this application.Data ...
7
votes
3
answers
6k
views
For the Platform Event "Automated Process" user, why do both Visualforce controller access and email sending fail?
We are executing some asynchronous code that uses getContentAsPdf on a Visualforce page as the result of handling custom platform event and we get this error in the Apex Jobs listing:
First error: [...
7
votes
1
answer
2k
views
How to get to the Id of batchableContext.getJobId() when handling a BatchApexErrorEvent?
I have a batch job that implements Database.RaisesPlatformEvents and when a BatchApexErrorEvent is generated from the Batch class's execute() method I handle it in a BatchApexErrorEventTrigger. I ...
7
votes
1
answer
444
views
Send Change Data Capture events from Managed Package
I am wrapping my head around the question of how to leverage Change Data Capture events in a customer's Managed Package app. They want to define a handful (= 10-15) of the packaged Custom Objects to ...
7
votes
1
answer
951
views
Custom Notifications not working on BatchApexErrorEvents
When long-running batches fail I want the starting user to be notified in the org using Custom Notifications.
Therefore I added the marker-interface Database.RaisesPlatformEvents to the Batch class
...
7
votes
1
answer
4k
views
403:denied_by_security_policy:create_denied when subscribing to platform events
This error is thrown when I try to subscribe to a platform event using the EMP-connector. I followed the steps outlined in the documentation:
https://developer.salesforce.com/docs/atlas.en-us.220.0....
7
votes
1
answer
669
views
Call Salesforce from AWS : Platform Events vs Custom Rest Service
Our's a real-estate client who stores Property record's image in AWS. As the user uploads photo in AWS, we need to identify the Property record based on the Image name and update its field in ...
6
votes
1
answer
927
views
Performance gains of moving automation into a trigger?
I'm working w/ a client who is running up against some limits for declarative automation. They are making robust use of workflow rules (above the limit), process builder (> 15), and a trigger.
I am ...
6
votes
2
answers
4k
views
Can I use platform event (which calls apex method) as alternative to future method?
Can I use platform event (which calls apex method) as an alternative to invoking future method from trigger? Is this against salesforce best practices?