Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
Step 2: Create a PushTopic (Legacy)
- Open the Developer Console.
- Click .
-
In the Enter Apex Code window, paste in the following Apex code, and click
Execute.
1PushTopic pushTopic = new PushTopic(); 2pushTopic.Name = 'InvoiceStatementUpdates'; 3pushTopic.Query = 'SELECT Id, Name, Status__c, Description__c FROM Invoice_Statement__c'; 4pushTopic.ApiVersion = 67.0; 5pushTopic.NotifyForOperationCreate = true; 6pushTopic.NotifyForOperationUpdate = true; 7pushTopic.NotifyForOperationUndelete = true; 8pushTopic.NotifyForOperationDelete = true; 9pushTopic.NotifyForFields = 'Referenced'; 10insert pushTopic;Because NotifyForOperationCreate, NotifyForOperationUpdate, NotifyForOperationDelete and NotifyForOperationUndelete are set to true, Streaming API evaluates records that are created, updated, deleted, or undeleted and generates a notification if the record matches the PushTopic query. Because NotifyForFields is set to Referenced, Streaming API will use fields in both the SELECT clause and the WHERE clause to generate a notification. Whenever the fields Name, Status__c, or Description__c are updated, a notification will be generated on this channel. For more information about NotifyForOperationCreate, NotifyForOperationUpdate, NotifyForOperationDelete, NotifyForOperationUndelete, and NotifyForFields, see Event Notification Rules.