You need to sign in to do that
Don't have an account?

pushtopic subscription in visualforce: does filtered subscription work?
I'm testing filtered subscriptions to pushtopics with a test visualforce page. This is the code:
Controller:
Visualforce page:
The string I'm passing as parameter for the subscribe method contains the filtering I need. the subscription works correctly, but doesn't filter, it gets all objects created despite whats the value of that field. Is the problem in the structure of the string, or doesn't it work this way? I can't find specific documentation for this. Any help is appreciated!
Controller:
public with sharing class PruebaPushTopicFiltradoController { public List<mlsales__Etiqueta_Zebra__c> etiquetas{get;set;} public PruebaPushTopicFiltradoController() { etiquetas = [SELECT Id, Documento_Id__c, Name, Identificacion_Impresora__c FROM Etiqueta_Zebra__c ORDER BY Name LIMIT 5]; } }
Visualforce page:
<apex:page standardStylesheets="false" controller="PruebaPushTopicFiltradoController" showHeader="TRUE" sidebar="false"> <link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" /> <div class="container"> <table id="oppTable" class="table table-hover table-bordered table-striped"> <thead> <tr> <th> Documento Id </th> <th> Name </th> <th> Identificacion Impresora </th> </tr> </thead> <tbody> <apex:repeat value="{!etiquetas}" var="etiqueta"> <tr> <td> {!etiqueta.Documento_Id__c} </td> <td> {!etiqueta.Name} </td> <td> {!etiqueta.Identificacion_Impresora__c} </td> </tr> </apex:repeat> </tbody> </table> </div> <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script> <script src="{!URLFOR($Resource.jsUtilities, '/js/json2.js')}"></script> <script src="{!URLFOR($Resource.jsUtilities, '/js/cometd.js')}"></script> <script src="{!URLFOR($Resource.jsUtilities, '/js/jquery.cometd.js')}"></script> <script> // initizlizing Streaming API (function($) { $(document).ready(function() { //Initializing cometd library to cometd endpoint $.cometd.init({ url: window.location.protocol + '//' + window.location.hostname + '/cometd/33.0/', requestHeaders: { Authorization: 'OAuth {!$Api.Session_ID}' }, appendMessageTypeToURL : false }); // Subscribing to the push topic. //JSON-encoded data will be returned in the callback each time whenever opportunity is created $.cometd.subscribe("/topic/getZebraToPrint?mlsales__Identificacion_Impresora__c='test'", function(message) { console.log(message); if (message.data.event.type == 'created') { console.log('created object ===> ' + message.data.sobject); var etiqueta = message.data.sobject; $("#oppTable > tbody").append('<tr class="success"><td>'+etiqueta.mlsales__Documento_Id__c+'</td><td>'+etiqueta.Name+'</td><td>'+etiqueta.mlsales__Identificacion_Impresora__c+'</td></tr>'); } }); }); })(jQuery) </script> </apex:page>
The string I'm passing as parameter for the subscribe method contains the filtering I need. the subscription works correctly, but doesn't filter, it gets all objects created despite whats the value of that field. Is the problem in the structure of the string, or doesn't it work this way? I can't find specific documentation for this. Any help is appreciated!
Caliburn AK2