In my canvas app I am running the example code given in the docs to get a signed request from a javascript file:

Sfdc.canvas.client.refreshSignedRequest(function(data) {
    if (data.status === 200) {
        var signedRequest =  data.payload.response;
        var part = signedRequest.split('.')[1];
        var obj = JSON.parse(Sfdc.canvas.decode(part));

however, the callback in this example never runs. I followed the code in the SDK and noticed a couple of things: 1st, the callback is referenced, but never called; 2nd, there is a function called callback which appears to be there to handle the callback passed in, but is not called (this is from the postit() function).

I'm still new to callbacks, but in all of the examples I've seen explaining them, the callback is called inside the function it's passed to. It is also my understanding the even if they are not called, they should still run once the parent function is finished.

I know that the refreshedSignedRequest() function is running because I can see that the signed request come across the network, just the callback getting the signed request never runs.

  • It looks like a framework I am using may be interrupting something in the canvas SDK code. After testing this code on a Heroku based canvas app in the canvas app previewer, I was able to see the above code work as intended. But then switching back to my app, the function failed. Jul 21, 2015 at 23:57

1 Answer 1


Canvas avoids cross-domain issues by sending messages between the iframes. So, instead of making the call directly to Salesforce servers, it sends a message to the parent of the iframe. (Included in this message is the source iframe window.name, so Salesforce knows which iframe to respond to.) A listener is listening for this message and does the actual call to refresh the signed request. When it gets the response, it serializes it and sends it back to the canvas iframe where a listener should be listening for that event.

(Edit: leaving this in here even though it wasn't the culprit) Perhaps something has overridden the message listener and it is being handled by another function instead. Look in your javascript for any calls to window.addEventListener to see if that is what is going on.

In your case, the problem is that the window.name is being modified inside the iframe so when the message is being sent across to Salesforce, it is missing the source window. Salesforce is getting the message, but then doesn't know where to send the signed request back to.

  • I found and confirmed that breeze.js is manipulating the window object properties, I believe, when at makes a query. Adjusting for this allows for a successful call of refreshSignedRequest() and the signed request comes back just fine. Aug 7, 2015 at 3:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .