I have a lightning cometd. When I use pushtopic without filter for a custom profile it works. When I add filter, it does not receive the messages. If I login as system admin, the filtered pushtopic subscription receives messages. This is a pushtopic on a custom object. I have FLS as read write for all the fields and create/modifyAll for Object level permission for this custom profile. I have enabled read permission on Pushtopic standard object permission. What am I missing ?
PushTopic code
PushTopic pushTopic = new PushTopic();
pushTopic.Name = 'AssignmentNotification';
pushTopic.Query = 'SELECT Id,user__c,userIdText__c FROM Assignment_Notification__c';
pushTopic.ApiVersion = 48.0;
pushTopic.NotifyForOperationCreate = true;
pushTopic.NotifyForOperationUpdate = false;
pushTopic.NotifyForOperationUndelete = false;
pushTopic.NotifyForOperationDelete = false;
pushTopic.NotifyForFields = 'Referenced';
insert pushTopic;
Cometd Code
subscribe: function(component, event) {
// Get the empApi component
const empApi = component.find("empApi");
let sid = component.get("v.sid");
let userId = component.get("v.userId");
// Get the channel from the input box
// const channel = "/topic/AssignmentNotification";
const channel = "/topic/AssignmentNotification?user__c="+userId;
// Replay option to get new events
const replayId = -1;
// Subscribe to an event
empApi
.subscribe(
channel,
replayId,
$A.getCallback(eventReceived => {
// Process event (this is called each time we receive an event)
console.log("Received event ", JSON.stringify(eventReceived));
// this.handleShowModal(component);
if (eventReceived.data.sobject.userIdText__c == userId)
this.openUtilNotification(component, event, eventReceived);
})
)
.then(subscription => {
// Confirm that we have subscribed to the event channel.
// We haven't received an event yet.
console.log("Subscribed to channel ", subscription.channel);
// Save subscription to unsubscribe later
component.set("v.subscription", subscription);
}).catch((error => console.log('error on receiving message '+JSON.stringify(error))))
.finally(()=> console.log('after receiving the message'));
}