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 Streaming API Developer Guide.

PushTopic events use the following database values to indicate work status:
  • ASSIGNED (0, “Assigned”)
  • UNAVAILABLE (1, “Unavailable”)
  • DECLINED (2, “Declined”)
  • OPENED (3, “Opened”)
  • CLOSED (4, “Closed”)
  • DECLINED_ON_PUSH_TIMEOUT (5, “DeclinedOnPushTimeout”)
  • CANCELLED (6, “Canceled”)
  • TRANSFERRED (7, “Transferred”)
1PushTopic pushTopic = new PushTopic();
2pushTopic.Name = PSRPushTopic;
3pushTopic.Query = 'Select Id, Serial, QueueId, WorkItemId, IsPushed, ServiceChannelId, LastDeclinedAgentSession, CreatedDate from PendingServiceRouting where RoutingModel = \'ExternalRouting\'';
4pushTopic.ApiVersion = 41.0;
5pushTopic.NotifyForOperationCreate = true;
6pushTopic.NotifyForOperationUpdate = true;
7pushTopic.NotifyForOperationDelete = true;
8pushTopic.NotifyForFields = 'Referenced';
9insert pushTopic;