Skip to content

Instantly share code, notes, and snippets.

Embed
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())
{
result='Cases';
}
return result;
}
public void CreateTopic()
{
System.debug('### Creating the push topic');
PushTopic pushTopic=new PushTopic();
pushTopic.Name='Cases';
pushTopic.Query='SELECT Id, Subject, OwnerId ' +
'FROM Case ';
pushTopic.ApiVersion=29.0;
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