Created
December 27, 2013 15:51
-
-
Save keirbowden/8148861 to your computer and use it in GitHub Desktop.
Custom controller for the streaming API browser notifications page.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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