Do the MVEL operators for filtered subscriptions described in Streaming API documentation really work?

I've tried a few variations of this (i.e. with/without quotes, double/single == etc.):

j$.cometd.subscribe("/topic/MyTopic?User__c=='{!$User.Id}'", callback);

And cannot get it to work (i.e. I cannot filter the records by user, I get ALL records). Does anyone have any experience of using this successfully?


To make sure I hadn't missed anything, I tried subscribing (separately) as follows:

j$.cometd.subscribe("/topic/MyTopic?User__c=='{!$User.Id}'", callback);
j$.cometd.subscribe("/topic/MyTopic?User__c=={!$User.Id}", callback);
j$.cometd.subscribe("/topic/MyTopic?User__c='{!$User.Id}'", callback);
j$.cometd.subscribe("/topic/MyTopic?User__c={!$User.Id}", callback);

I examined the Request Payload using Chrome and it appears that nothing has gone awry:

[{  "channel":"/meta/subscribe",
    "clientId":"85d1vkpu673gnvdq1mt73bp37xyz" }]

And still, each time I still get ALL records instead of filtered by my User ID.

  • I've used MVEL operators with the Faye client successfully. Can you inspect the network traffic and confirm the cometd client is not URL encoding your apostrophes? Or that it's not trashing the entire query string? – bigassforce May 12 '14 at 14:10
  • Yep, good idea - will take a squizz and update - cheers dude – Phil Hawthorn May 12 '14 at 15:23
  • Is the PushTopic you inserted of a sufficient API version to support MVEL operator filters? – bigassforce May 12 '14 at 18:44
  • Yes, pushTopic.ApiVersion = 29.0; – Phil Hawthorn May 12 '14 at 18:49
  • hmm, can you post exact code (client and server) as a gist? perhaps a dump of sample data? – bigassforce May 12 '14 at 21:03


basic filtering available in the form:


Conditions can be combined by using an & for example:


This translates into OR condition: User__c == 005A0000000gqi6IAA OR Id == {ID-18Char}

This is not nearly as robust as MVEL operations but can help reduce the number of received events

John Brock from Salesforce confirms that MVEL Operators have been removed from the Salesforce Streaming API for the time being. They are looking into other options.

The last time I saw this working was API 27.0 and using an old PushTopic version or an old subscription header may not work either. Thanks to Andrew Fawcett for confirming this.

| improve this answer | |
  • Cheers Matt & Andy – Phil Hawthorn Sep 29 '14 at 15:47
  • bigassforce is correct -- we are currently investigating potential options to improve or replace MVEL filtering. MVEL has been disabled for all API versions so using v27 will not work. – John Brock Nov 10 '14 at 8:27
  • 1
    Note: we do have basic filtering available in the form of: /topic/MyTopic?User__c=005A0000000gqi6IAA Conditions can be combined by using an '&' ie: /topic/MyTopic?User__c=005A0000000gqi6IAA&Id={ID-18Char} which translates into and OR condition: User__c == 005A0000000gqi6IAA OR Id == {ID}. This is not nearly as robust as MVEL operations but it can help reduce the number of received events. – John Brock Aug 14 '15 at 0:09
  • This is super! Thanks for the good news @JohnBrock – bigassforce Aug 14 '15 at 0:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.