Streaming API MVEL Operators

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.

Answer

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.

Attribution
Source : Link , Question Author : Phil Hawthorn , Answer Author : Community

Leave a Comment