• Prabhjot Singh 27
  • NEWBIE
  • 15 Points
  • Member since 2017
  • Senior Software Engineer
  • Optum / United Health Group


  • Chatter
    Feed
  • 0
    Best Answers
  • 9
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 8
    Replies
While implementing emp API in LWC to subscribe the platform event I  find out that there is small issue in sample code snipit given in documentation.
Issue is in handleSubscribe method in js below is the code given in documentation:
handleSubscribe() {
        // Callback invoked whenever a new event message is received
        const messageCallback = function(response) {
            console.log('New message received : ', JSON.stringify(response));
            // Response contains the payload of the new message received
        };

        // Invoke subscribe method of empApi. Pass reference to messageCallback
        subscribe(this.channelName, -1, messageCallback).then(response => {
            // Response contains the subscription information on successful subscribe call
            console.log('Successfully subscribed to : ', JSON.stringify(response.channel));
            this.subscription = response;
            this.toggleSubscribeButton(true);
        });
    }
 Correction is required in messageCallback method which should be as below:
const messageCallback = (response) => {
        console.log('New message received : ', JSON.stringify(response));
        this.payload = JSON.stringify(response);
        console.log('this.payload: ' + this.payload);
        // Response contains the payload of the new message received
    };
We have to use arrow function as it does not have its own scope.  
Trying to implement LWC - empApi  for publishing and subscribing platform event . 
Salesforce provided an example on:
https://developer.salesforce.com/docs/component-library/bundle/lightning-emp-api/documentation
But I  am getting issue on this as well 
While implementing emp API in LWC to subscribe the platform event I  find out that there is small issue in sample code snipit given in documentation.
Issue is in handleSubscribe method in js below is the code given in documentation:
handleSubscribe() {
        // Callback invoked whenever a new event message is received
        const messageCallback = function(response) {
            console.log('New message received : ', JSON.stringify(response));
            // Response contains the payload of the new message received
        };

        // Invoke subscribe method of empApi. Pass reference to messageCallback
        subscribe(this.channelName, -1, messageCallback).then(response => {
            // Response contains the subscription information on successful subscribe call
            console.log('Successfully subscribed to : ', JSON.stringify(response.channel));
            this.subscription = response;
            this.toggleSubscribeButton(true);
        });
    }
 Correction is required in messageCallback method which should be as below:
const messageCallback = (response) => {
        console.log('New message received : ', JSON.stringify(response));
        this.payload = JSON.stringify(response);
        console.log('this.payload: ' + this.payload);
        // Response contains the payload of the new message received
    };
We have to use arrow function as it does not have its own scope.  
While implementing emp API in LWC to subscribe the platform event I  find out that there is small issue in sample code snipit given in documentation.
Issue is in handleSubscribe method in js below is the code given in documentation:
handleSubscribe() {
        // Callback invoked whenever a new event message is received
        const messageCallback = function(response) {
            console.log('New message received : ', JSON.stringify(response));
            // Response contains the payload of the new message received
        };

        // Invoke subscribe method of empApi. Pass reference to messageCallback
        subscribe(this.channelName, -1, messageCallback).then(response => {
            // Response contains the subscription information on successful subscribe call
            console.log('Successfully subscribed to : ', JSON.stringify(response.channel));
            this.subscription = response;
            this.toggleSubscribeButton(true);
        });
    }
 Correction is required in messageCallback method which should be as below:
const messageCallback = (response) => {
        console.log('New message received : ', JSON.stringify(response));
        this.payload = JSON.stringify(response);
        console.log('this.payload: ' + this.payload);
        // Response contains the payload of the new message received
    };
We have to use arrow function as it does not have its own scope.  
Trying to implement LWC - empApi  for publishing and subscribing platform event . 
Salesforce provided an example on:
https://developer.salesforce.com/docs/component-library/bundle/lightning-emp-api/documentation
But I  am getting issue on this as well 
Hi All,

I am using sforce.one.navigateToSObject method in one of my edit page. I am calling an javascript method from my custom button which inturns calls  this method and redirecting to an record.
i am editing the record in my VF page  and redirecting to its detail page with sforce.one.navigateToSObject method.
This method redirects  but does not refreshes the page with my updated value.

i have used Sfdc.canvas.publisher.publish({name: "publisher.close", payload:{refresh:"true"}}); also which did not help me.

please help me

Thanks in advance

 

Recently a new option is added on VF Page compiler in salesforce what does it mean?