• Laurent Lemire
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 4
    Replies
Is there a way to detect the size of the visualForce page so that the canvas app can be resized accordingly?
Hi,

I have a canvas in a visualforce page that upload an document to the notes and attachment tab, but after sending the document, it will not appear until I refresh the whole page, so I was wondering if it was possible to refresh the notes and attachment tab after it received the new document.

With events, my canvas app can notify my visualforce page when the upload is finished, but I can't seem to find a way to just refresh part of the page.

If anyone could help me with this, it would be great.
Hi,

I am currently making a connected app that connects with salesforce using the OAuth Webflow access method. So I've been looking at the doc and I've put this code into my web app : 
<html>
<head>
    <script type="text/javascript" src="/sdk/js/canvas-all.js"></script>
</head>
<body>
    <script>

        function loginHandler(e) {
            var uri;
            if (! Sfdc.canvas.oauth.loggedin()) {
                uri = Sfdc.canvas.oauth.loginUrl();
                Sfdc.canvas.oauth.login(
                    {uri : uri,
                        params: {
                            response_type : "token",
                            client_id : "3MVG9lKcPoNINVBLigmW.8dAn4L5HwY VBzxbW5FFdzvU0re2
                                f7o9aHJNUpY9ACdh.3SUgw5rF2nSsC9_cRqzD",
                            redirect_uri : encodeURIComponent(
                                "https://demoapp1234.herokuapp.com/sdk/callback.html")
                        }});
            }
            else {
                Sfdc.canvas.oauth.logout();
                login.innerHTML = "Login";
                Sfdc.canvas.byId("oauth").innerHTML = "";
            }
            return false;
        }

        // Bootstrap the page once the DOM is ready.
        Sfdc.canvas(function() {
            // On Ready...
            var login    = Sfdc.canvas.byId("login"),
                loggedIn = Sfdc.canvas.oauth.loggedin(),
                token = Sfdc.canvas.oauth.token()
            login.innerHTML = (loggedIn) ? "Logout" : "Login";
            if (loggedIn) {
                 // Only displaying part of the OAuth token for better formatting.
                Sfdc.canvas.byId("oauth").innerHTML = Sfdc.canvas.oauth.token()
                    .substring(1,40) + "…";
            }
            login.onclick=loginHandler;
        });
    </script>
    <h1 id="header">Force.com Canvas OAuth App</h1>
    <div>
        access_token = <span id="oauth"></span>
    </div>
    <div>
        <a id="login" href="#">Login</a><br/>
    </div>
</body>
</html>

I understand how the code is supposed to work, but for an unknown reason, my browser console says this : 
Uncaught ReferenceError: Sfdc is not defined
    at eval (eval at <anonymous> (jquery-1.12.4.min.js?v=cWplNnVObXpZU0NRS2tueHgwYlR5bGhmcE82bVAveVVEM05xY0JDZ2xxZz01:2)
I can see that my canvas-all.js is loaded correctly, so I don't understand what the problem is.
Please Help!
Hi, 

I made a connected app using canvas that point to a .NET project, but when I try to open it in the previewer, in a visualforce page or at na78.visual.force.com/apex/Page_Name all I can see is : 

localhost sent an invalid response

There is nothing in the browser console and if I use the onCanvasAppLoad parameter in my <apex:canvasApp />, I have the confirmation that my app is loaded correctly.
Is there a way to detect the size of the visualForce page so that the canvas app can be resized accordingly?
Hi,

I am currently making a connected app that connects with salesforce using the OAuth Webflow access method. So I've been looking at the doc and I've put this code into my web app : 
<html>
<head>
    <script type="text/javascript" src="/sdk/js/canvas-all.js"></script>
</head>
<body>
    <script>

        function loginHandler(e) {
            var uri;
            if (! Sfdc.canvas.oauth.loggedin()) {
                uri = Sfdc.canvas.oauth.loginUrl();
                Sfdc.canvas.oauth.login(
                    {uri : uri,
                        params: {
                            response_type : "token",
                            client_id : "3MVG9lKcPoNINVBLigmW.8dAn4L5HwY VBzxbW5FFdzvU0re2
                                f7o9aHJNUpY9ACdh.3SUgw5rF2nSsC9_cRqzD",
                            redirect_uri : encodeURIComponent(
                                "https://demoapp1234.herokuapp.com/sdk/callback.html")
                        }});
            }
            else {
                Sfdc.canvas.oauth.logout();
                login.innerHTML = "Login";
                Sfdc.canvas.byId("oauth").innerHTML = "";
            }
            return false;
        }

        // Bootstrap the page once the DOM is ready.
        Sfdc.canvas(function() {
            // On Ready...
            var login    = Sfdc.canvas.byId("login"),
                loggedIn = Sfdc.canvas.oauth.loggedin(),
                token = Sfdc.canvas.oauth.token()
            login.innerHTML = (loggedIn) ? "Logout" : "Login";
            if (loggedIn) {
                 // Only displaying part of the OAuth token for better formatting.
                Sfdc.canvas.byId("oauth").innerHTML = Sfdc.canvas.oauth.token()
                    .substring(1,40) + "…";
            }
            login.onclick=loginHandler;
        });
    </script>
    <h1 id="header">Force.com Canvas OAuth App</h1>
    <div>
        access_token = <span id="oauth"></span>
    </div>
    <div>
        <a id="login" href="#">Login</a><br/>
    </div>
</body>
</html>

I understand how the code is supposed to work, but for an unknown reason, my browser console says this : 
Uncaught ReferenceError: Sfdc is not defined
    at eval (eval at <anonymous> (jquery-1.12.4.min.js?v=cWplNnVObXpZU0NRS2tueHgwYlR5bGhmcE82bVAveVVEM05xY0JDZ2xxZz01:2)
I can see that my canvas-all.js is loaded correctly, so I don't understand what the problem is.
Please Help!
Hi, 

I made a connected app using canvas that point to a .NET project, but when I try to open it in the previewer, in a visualforce page or at na78.visual.force.com/apex/Page_Name all I can see is : 

localhost sent an invalid response

There is nothing in the browser console and if I use the onCanvasAppLoad parameter in my <apex:canvasApp />, I have the confirmation that my app is loaded correctly.

I'm using C# and SF REST API. I have no problems so far get-ing and inserting some custom data from SF (Accounts,etc..). But now a have to insert PDF attachment using REST API, and i'm stuck. I's  it even possible? And if it is how? Any help will be appreciated.