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 Invoice_Statement__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
8      "createdDate":"2016-03-29T16:40:08.208Z",
9      "replayId":13,
10      "type":"created"
11
12    },
13    "sobject":
14    {
15      "Name": "INV-0001", 
16      "Id": "a00D0000008o6y8IAA",
17      "Status__c": "Open"
18    }
19  }
20}

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.

In API version 37.0 and later, the time format of the createdDate field value has changed to make it consistent with the time format used in the Salesforce app. The time portion now ends with a Z suffix instead of +0000. Both suffixes denote a UTC time zone.

Note