function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Streaming API - Multiple Subscriptions

Hi all,

I have two topics that I want to subscribe to in my JS, but am having difficulty in doing so.  Any suggestions?






How would I add topic2 as an additional subscripiton?


$.cometd.subscribe('topic/topic1', function(message) {



I have this same requirement. After taking a look into wildcard subscriptions, I believe this is possible. Unfortunately, I believe this may mean essentially subscribing to all pushtopics created in our orgs and then using an IF conditional to check that the message is coming from one of the topics we actually care about for the current page. I think some javascript that looks like the following should do the trick:


$.cometd.subscribe('/topic/*', function(message) {

    if ( === '/topic/topic1' || === '/topic/topic2'){
        //Do Something


  Full Disclaimer: I haven't implemented this to make sure it works, but given what I read I believe this should solve our problem. Happy coding!


Bad news: no deposit, no return. Unfortunately this method didn't seem to pan out for me. I thought it would work because if you follow standard SF protocol by applying to only one topic and then doing a JS alert of the field you will indeed get the name displayed on the screen. Unfortunately I suppose for the time being Salesforce does not support wildcard subscriptions. That said, YMMV - let me know if you're able to sort this one out and sorry I wasn't of more help!