Skip to content

Instantly share code, notes, and snippets.

@keirbowden
Created December 27, 2013 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keirbowden/8148861 to your computer and use it in GitHub Desktop.
Save keirbowden/8148861 to your computer and use it in GitHub Desktop.
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