3

I am trying few examples such as to display a canvas app which is built in SAP webDynpro. I am wondering if it is possible to exchange data between Canvas App and visualforce page where the app is embedded.

I understand that multiple canvas app on a visualforce page can exchange data between them through publish and subscribe methods. But is that possible to send and receive data between Canvas app and Visualforce page? I am assuming that we can send (POST) data to canvas app through parameters attribute in <apex:canvasApp. Is that right?

Scenario:

For example if the canvas app is an "Add Order" page through which I can add an order. But once the order is created i need that newly created order number passed back to my visualforce page so that i can use it in apex to apply some logic and store the order id in order object in salesforce.

Any experts advice would be much apprciated.

Thanks, Baskaran

  • What do you mean by use and persist? Can you say more. – greenstork May 21 '14 at 16:40
  • Thanks @greenstork. I meant it to use the data from canvas app in the apex code and store (persists) the order id in Order object. I am going to change my wordings. – Bforce May 21 '14 at 16:42
3

Canvas apps allow you to interact with your embedded app via the publish (pushing data from your page to you app) and subscribe (receiving data from your app) javascript functions. If you needed the data from the canvas app in apex, then you would need to use a combination of the subscribe function and javascript remoting. Here is some stub code:

Sfdc.canvas(function() {
    sr = JSON.parse('<%=signedRequestJson%>');
    Sfdc.canvas.client.subscribe(sr.client,
        {name : 'mynamespace.orderSubmitted', onData : function (event) {
            //call my JS remoting method to do something with the order data
        }}
    );
}
  • Thanks @greenstork. So, i need to use this js in my visualforce page to get the response from canvas app. Also the canvas app should be publishing data. Is that right? – Bforce May 21 '14 at 17:13
  • Yes, correct. You night check out the Salesforce Canvas SDK for implementing the post/publish flow on the SAP side: github.com/forcedotcom/salesforcecanvasframeworksdk – greenstork May 21 '14 at 17:25
  • Thanks a lot @greenstork. I would check the documentation now. – Bforce May 21 '14 at 17:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.