Newer Version Available

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

Step 2: Create a PushTopic for PendingServiceRouting

A PushTopic is a query that is the basis for notifying listeners of changes to records in an organization. Create a PushTopic for PendingServiceRouting so partners can receive event notifications.
Reference the following code sample to create a PushTopic using Apex code. If you need help creating a PushTopic, see Create a PushTopic in the Force.com Streaming API Developer Guide.
1PushTopic pushTopic = new PushTopic();
2pushTopic.Name = myPSR;
3pushTopic.Query = 'Select Id, Serial, QueueId, WorkItemId, IsPushed, ServiceChannelId, LastDeclinedAgentSession, CreatedDate from PendingServiceRouting where RoutingModel = 'ExternalRouting'';
4pushTopic.ApiVersion = 39.0;
5pushTopic.NotifyForOperationCreate = true;
6pushTopic.NotifyForOperationUpdate = true;
7pushTopic.NotifyForOperationDelete = true;
8pushTopic.NotifyForFields = 'Referenced';
9insert pushTopic;