14

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?

EDIT:

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",
    "subscription":"/topic/MyTopic?User__c=='005A0000000gqi6IAA'",
    "id":"2",
    "clientId":"85d1vkpu673gnvdq1mt73bp37xyz" }]

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

8
  • 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? May 12, 2014 at 14:10
  • Yep, good idea - will take a squizz and update - cheers dude May 12, 2014 at 15:23
  • Is the PushTopic you inserted of a sufficient API version to support MVEL operator filters? May 12, 2014 at 18:44
  • Yes, pushTopic.ApiVersion = 29.0; May 12, 2014 at 18:49
  • hmm, can you post exact code (client and server) as a gist? perhaps a dump of sample data? May 12, 2014 at 21:03

1 Answer 1

5

Update:

basic filtering available in the form:

/topic/MyTopic?User__c=005A0000000gqi6IAA

Conditions can be combined by using an & for example:

/topic/MyTopic?User__c=005A0000000gqi6IAA&Id={ID-18Char}

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.

4
  • Cheers Matt & Andy Sep 29, 2014 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, 2014 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, 2015 at 0:09
  • This is super! Thanks for the good news @JohnBrock Aug 14, 2015 at 0:42

You must log in to answer this question.

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