Saturday, November 11, 2017

Salesforce Canvas : what and how?

When we are integrating third party UI application, there are quite a few options

  • Including iframe inside Visualforce or Lightning component
    • mostly one way integration (salesforce to UI application)
    • security issues
    • sizing problems
  • Canvas
    • lightning and classic
    • seamless and two way integration
  • Lightning container component (Winter'18 - for lightning)
    • only for lightning
Canvas by far the most feature rich and seamless integration between salesforce and third party UI application, especially we have two way interaction. E.g. salesforce passing data to third party application and UI application updating/creating data back in salesforce.
How to configure it

  • Create Connected application

Step 1) Connected App -> Allow users to install canvas personal apps

Step 2) Create New App






Step 3) Configure Canvas App Settings  (Note: check Publisher and Create Actions, if we plan to publish canvas app there)



Step 4)



Step 5) Grab the consumer secret and key



Step 6) Assign canvas app the users or profiles







Step 7) Canvas app viewer






  • Sample Third Party application
    • From Canvas App viewer, we can create canned "heroku quick start" app, however I decided to use create my own so that I can test out all the features in controller environment
    • Create heroku application, and make sure to sign the request for the URL provided in canvas salesforce app



Main Features

Security
  • Salesforce sends signed request to third party application, and it can be decrypted using consumer key. Hence the request is secure.
  • Also when json request payload is decrypted, we get session id and all the information of the page context  






Two way event
- Events can be raised from Visual Force and can be sent to Third Party App, and Third party app can send event back to Salesforce






Resize
- Third party App can use resize API to resize the canvas size in Salesforce. When we put canvas in visualforce and then in layout, we are restricted by iFrame size and height, but if canvas is put in directly in page layout we can have much better control over the size.







Api calls (e.g. chatter)

Third party application can use OAuth token provided in JSON request and make any API call. Below is example of chatter post




Where canvas can be used 
Once it is configured correctly, it can be used at many places:


Canvas App Previewer : this is just for testing your canvas app



Page layout via Visual Force
Canvas can be added in visual force page, however if we go that route, when we add the page to layout, we will be restricted by iframe size.



VisualForce code:




Page Layout Directly
This is very advantageous as we can resize and don't have to use iframe




Lightning Component
We can add canvas in lightning component







Chatter / Publish Action
We can also put canvas chatter or publisher action as shown below





Source Code

Heroku code 
https://github.com/c-shah/canvasly

Salesforce code
https://github.com/c-shah/sf.canvasly

12 comments:

Suba said...

Salesforce CRM tool helps business to track customer information of your business and the tool provides the detailed information of customer activities related to your business….You provide us detailed information on the complete guidance of Salesforce CRM tool.
Regards:
Salesforce Course
Salesforce Developer Training

Unknown said...

Quite Interesting post!!! Thanks for posting such a useful post. I wish to read your upcoming post to enhance my skill set, keep blogging.
Regards,
Salesforce Training in Chennai|Salesforce Course in Chennai

sharmi said...

I have never read more interesting articles than yours before. You make me so easy to understand and I will continue to share this site. Thank you very much and more power
DevOps Training in Chennai
DevOps Certification
DevOps Certification Chennai

Unknown said...

Hi Chintan,

I am getting 404 error on deploying on the server. I cannot find web\inf folder in github of canvas app. Please help me resolving the error

Unknown said...

i had configured custom attributes in my canvas app, but these attributes are not passing into Canvas signed request, could anyone please help

shalini said...

good.....nice..
category/maintenance-resume
category/manager-resume
category/mechanical-engineering-resume
category/network-engineer-resume
category/officer-resume
category/operations-resume
category/process-associate-resume
category/quality-control-resumes
category/software-engineer-resume

shalini said...

good .........very useful
fresher-marketing-resume-sample
front-end-developer-resume-sample
full-stack-developer-resume-samples
fund-accountant-resume-samples
general-ledger-accountant-resume-sample
government-jobs-resume
hadoop-developer-sample-resume
hadoop-developer-sample-resume
hardware-and-networking-resume-samples
hardware-engineer-resume-sample

Praisy Margret said...

useful information..nice..
devops-engineer-resume-samples
digital-marketing-resume-samples
digital-marketing-resume-samples
electronics-engineer-resume-sample
engineering-lab-technician-resume-samples
english-teacher-cv-sample
english-teacher-resume-example
english-teacher-resume-sample
excel-expert-resume-sample
executive-secretary-resume-samples

onesiti said...

Way cool! Some very valid points! apps I appreciate you writing this post plus the rest of the website is also really good.

Unknown said...

Is it necessary to host my external application to Heroku if I want to leverage it in Salesforce using Canvas?

livoci said...

Wow! Fantastic article man! Much obliged to you, However I am experiencing issues with your RSS. I don't comprehend the motivation behind why I can't go along with it. Is there any other person having a similar RSS issues? Anyone who realizes the appropriate response will you generously react? Much appreciated!!
live

Hi Every One said...

I have Microsoft Office 2016 installed on a computer that I am replacing and I cannot find the DVD/Product Key. Is there any way to get Download MS Office 2016 With Crack