I have a very simple component:

<aura:component implements="flexipage:availableForAllPageTypes" access="global">
    <lightning:empApi aura:id="empApi"/>
    <aura:handler name="init" value="{!this}" action="{!c.onInit}"/>

    onInit: function(component, event, helper) {
        var empApi = component.find("empApi");
        empApi.subscribe("/topic/AccountChanges?Id=0011t0000033C9QAAU", -1, function(message) {
            console.log("Event Received : " + JSON.stringify(message));

I also have PushTopic created like this: PushTopic Screenshot

What I am trying to do, is to only receive events for specific record Id. Based on documentation this should work: "/topic/AccountChanges?Id=0011t0000033C9QAAU", but it doesn't.

"/topic/AccountChanges" works though.

I've tried Id='0011t0000033C9QAAU' aswell, but no luck.

Do you know if it is possible at all?

  • 3
    The filtered subscription doesn't even seem to be working when subscribed from say a java client using emp connector. The connection itself fails if filtered subscription is provided as an argument to the emp connector client
    – Jayant Das
    Nov 5, 2018 at 18:42

4 Answers 4


Filtering is not available for subscriptions to Change Data Capture event streams. Only PushTopic streams exposed the ability for filtered subscriptions https://developer.salesforce.com/docs/atlas.en-us.api_streaming.meta/api_streaming/using_filtered_subscriptions.htm. We are prioritizing this work, but there the effort will require a few releases for GA.

Change Data Capture events : /data/*
PushTopic Streaming : /topic/*
Platform Events : /event/*
Generic Streaming : /u/*


There is a known bug about this issue: empapi-can-t-process-event-notifications-using-filtered-subscription-during-aura-component-initialization

The thing is that you can't do this filtered subscription during the init process of the component. As a workaround you can create a button and do the subscription from the button click.

<input type="button" value="subscribe" onclick="{!c.subscribe}" id="mybutton"/>

To automate this click you can set a timer into the init process to call the button click process, just a timer calling the subscribe on the helper didn't work for me so I had to do this workaround with the button.


In the controller include the subscribe function:

subscribe: function (component, event, helper) {
    helper.subscribe(component, event, helper);

In the helper do the subscription implementing the subscribe process as per your needs.

It's working for me. Hope it helps.

  • Does this bug still exist in 2020? Can we now use the filtering technique posed the question on the component initializer? Jan 15, 2020 at 19:26

Jayant - Sorry you encountered this error. I confirmed that this is indeed a recent issue with subscription filtering in EMP Connector and the empApi component. Salesforce is working on a fix. We have a PR for EMP Connector that fixes this problem here: https://github.com/forcedotcom/EMP-Connector/pull/43/files

  • Thanks for the update. I will definitely check it out after it is fixed. Nov 13, 2018 at 13:35
  • @Katia - Do you know if this has been resolved? Seems this was encountered again, here's the reference
    – Jayant Das
    Mar 20, 2019 at 15:34

I can confirm in 2023 PushTopic filtering works. However, the documentation is slightly incorrect. Per Documentation examples and notes. https://developer.salesforce.com/docs/atlas.en-us.api_streaming.meta/api_streaming/using_filtered_subscriptions.htm

/topic/MyTopic?Industry='Energy'&ShippingCity='San Francisco'

When using a shared CometD session with the empApi Lightning component, all subscriptions to the same PushTopic must specify the same filter. If the initial subscription doesn't use a filter, the subsequent subscriptions can't. For example, if you subscribe to /topic/MyTopic?Name='SomeName', you can’t resubscribe to /topic/MyTopic or /topic/MyTopic?Industry='Energy' using the same CometD session. Shared CometD sessions apply to subscriptions you make with the empApi Lightning component only. The empApi component shares the CometD session when you open a second instance of empApi in a new tab, or in a new browser for the same Salesforce user session.

Stripping out the apostrophes (which if real should've been URL encoded to %27) this format does work.


However, this doesn't work for Platform Events in this exact form. I get the event, but I get them all.


You must log in to answer this question.

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