0

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'));   
  }
4
  • Questions about implementation problems need to include a specific description of the problem (including exact errors and stack traces, if any) and the code or metadata to reproduce the problem. Please limit code inclusions to only the relevant elements, such as an MVR (minimum viable reproduction).
    – identigral
    Commented Jun 4, 2020 at 18:30
  • 1
    I have added code to the original question. Thanks for your feedback Commented Jun 4, 2020 at 18:44
  • @RajaVivekanandhan did you found any solution ? Commented Jul 25 at 15:21
  • I had to change the implementation since cometD limits to 2000 concurrent usage. I didn't remember solving the original problem posted here @sfdeveloper Commented Aug 16 at 18:00

0

You must log in to answer this question.

Browse other questions tagged .