Intuitively I would think this is how to do it, but it does not work.

pushTopic.Query = 'SELECT id, name, Doer__c from Object1__c WHERE Doer__c =: UserInfo.getUserId()'; 
pushTopic.ApiVersion = 29.0;


System.DmlException: Insert failed. First exception on row 0; first error: INVALID_FIELD, unexpected token: ':': [Query]: AnonymousBlock: line 9, column 1

  • 2
    Have you tried storing UserInfo.getUserId() in a variable and then binding against the variable? Also, what context is this running in? A VF controller?
    – Mike Chale
    Jan 8, 2014 at 19:15

1 Answer 1


While evaluating the variable and then substituting it might help the creation of one, your PushTopics are ultimately going to proliferate (and you must hoover them up as your users change).

Why not use Streaming API filtered subscriptions? You can insert a PushTopic like:

insert new PushTopic(
    Name        = 'Doers',
    Query       = 'SELECT Id, Doer__c FROM Object1__c', //WHERE <snip>
    ApiVersion  = 29.0


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


You must log in to answer this question.

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