Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Salesforce
  3. Question
Salesforce

How can we populate the variable sr in the line - #[removed][removed](document.getelementsbyname("signed_request")[0].value);

Asked by Anu Rhea May 3, 2023 863 views 1 answer
Share

About this question

We haven't figured out how to get the signed request (sr) in the visualforce page where we have a canvas app.

We are publishing a canvas event in our external app like:

Sfdc.canvas.client.publish(sr.client, { name : "namespace.eventName", payload : {status : 'Completed'} } );

And first we try to subscribe to the event in the VF page like:

[removed][removed]  Sfdc.canvas(function() { Sfdc.canvas.controller.subscribe( { name : ‘namespace.eventName’, onData : function(e) { console.log("Subscribed to custom event ", e); } }); });

but we are getting the error Uncaught TypeError: Cannot read property 'publish' of undefined meaning that controller is undefined

So, we want to subscribe using the Sfdc.canvas.client.subscribe but that method takes two parameters, one of them is the signed request which we don't know how to get in the VF page

Eg:
});
Sfdc.canvas(function() { sr = JSON.parse('<%=signedRequestJson%>'); Sfdc.canvas.client.subscribe(sr.client, {name : 'mynamespace.statusChanged', onData : function (event) { console.log("Subscribed to custom event ", event); }} );
So, the question is, how can we populate the variable sr in the line sr = JSON.parse('<%=signedRequestJson%>');?

Your answer

1 Answer

More Salesforce discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Salesforce Blogs

Guides, tips and career advice on Salesforce from JanBask experts.