Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Custom controller for the streaming API browser notifications page.
public with sharing class StreamingController
public String getTopic()
String result='';
List<PushTopic> topics=[select id, Name from PushTopic where Name='Cases'];
if (0!=topics.size())
return result;
public void CreateTopic()
System.debug('### Creating the push topic');
PushTopic pushTopic=new PushTopic();
pushTopic.Query='SELECT Id, Subject, OwnerId ' +
'FROM Case ';
pushTopic.NotifyForOperationCreate = true;
pushTopic.NotifyForOperationUpdate = true;
pushTopic.NotifyForOperationUndelete = true;
pushTopic.NotifyForOperationDelete = true;
pushTopic.NotifyForFields = 'Referenced';
insert pushTopic;
System.debug('### Done creating the push topic - id = ' + pushTopic.Id);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment