Newer Version Available

This content describes an older version of this product. View Latest

PushTopic Queries

The PushTopic query is the basis of the PushTopic channel and defines which record create, update, delete, or undelete events generate a notification. This query must be a valid SOQL query. To ensure that notifications are sent in a timely manner, the following requirements apply to PushTopic queries.

  • The query SELECT clause must include Id. For example: SELECT Id, Name FROM....
  • Only one entity per query.
  • The object must be valid for the specified API version.

The fields that you specify in the PushTopic SELECT clause make up the body of the notification that is streamed on the PushTopic channel. For example, if your PushTopic query is SELECT Id, Name, Status__c FROM InvoiceStatement__c, then the ID, Name and Status__c fields are included in any notifications sent on that channel. Following is an example of a notification message that might appear in that channel:

1{   
2  "channel": "/topic/InvoiceStatementUpdates",
3  "data":
4  {
5    "event":
6    {
7      "type": "updated",
8      "createdDate": "2011-11-03T15:59:06.000+0000"
9    },
10    "sobject":
11    {
12      "Name": "INV-0001", 
13      "Id": "a00D0000008o6y8IAA",
14      "Status__c": "Open"
15    }
16  }
17}

If you change a PushTopic query, those changes take effect immediately on the server. A client receives events only if they match the new SOQL query. If you change a PushTopic Name, live subscriptions are not affected. New subscriptions must use the new channel name.