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

18 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

sibiselvan said...

it is good blogs!!!

paid internships in pune for computer science students
machine learning training in chennai
data science internship in chennai
dot net training in chennai
kaashiv infotech chennai
internship for aeronautical engineering students in india
internship in automobile industry
big data internship in chennai
machine learning internship in chennai
internship in chennai for it students

Muthu said...

Nice post...
3d-modeler-resume-samples
3d modeler resume samples
accounting-assistant-resume-sample
accounting-clerk-resume-sample
accounting-manager-resume-samples
account-manager-resume-examples
accounts-payable-resume-sample
admin-manager-resume-samples
advocate-resume-sample
advocate-resume-sample

sugan said...

excellent.....
apache solr resume sample
apache spark sample resume
application developer resume samples
application support engineer resume sample
asp dotnet mvc developer resume
asp net core developer resume
asp net developer resume samples
assistant accountant cv sample
assistant accountant resume
assistant accountant resume sample

shalini said...

nice....
category/advocate-resume
category/agriculture-forestry-fishing
category/android-developer-resume
category/assistant-professor-resume
category/chartered-accountant-resume
category/database-resume
category/design-engineer-resume
category/developer-resume
category/engineer-resume
category/entrepreneur-and-financial-services-resume

reena said...

branch-operations-manager-resume-samples
business-executive-resume-samples
business-owner-resume-samples
business-to-business-sales-resume-sample-sales-resumes
cad-design-engineer-resume-samples
call-centre-jobs-resume-sample
ca-resume-samples-chartered-accountant-resume-format
cassandra-database-administrator-resume
category/accountant-resume
category/admin-resume

Praisy Margret said...

good..nice..
assistant-director-resume-format
assistant-director-resume-sample
assistant-professor-resume-sample
back-office-executive-resume-samples
bank-branch-manager-resume-samples
basketball-coach-resume-sample-coach-resumes
bca-fresher-resume-sample
best-general-manager-resume-example
bpo-resume-freshers-sample
bpo-resume-samples-for-freshers

reena said...

good ....nice...
resume/category/software-testing-resume
resume/category/sslc-resume
resume/category/storekeeper-resume
resume/category/stylist-resume
resume/category/teachers-resume
resume/category/technical-architect-resume
resume/category/web-developer-resume
cics-system-programmer-resume-example
resume/cisco-network-engineer-resume
resume/cisco-network-engineer-resume-sample

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

Praisy Margret said...

good... nice... very useful..
assistant-director-resume-format
director-resume-sample
assistant-professor-resume-sample
back-office-executive-resume-samples
bank-branch-manager-resume-samples
basketball-coach-resume-sample-coach-resumes
bca-fresher-resume-sample
best-general-manager-resume-example
bpo-resume-freshers-sample
bpo-resume-samples-for-freshers

sibiselvan said...

it is best blogs ....

civil-engineer-resume-format
client-service-executive-resume-sample
cognos-developer-resume-samples
college-lecturer-resume
college-lecturer-resume-sample
commercial-assistant-resume-sample
compliance-officer-resume-samples
computer-teacher-resume-format
computer-teacher-resume-sample
cordova-developer-resume-sample

reena said...



film-director-resume
finance-and-accounting-manager-resume-samples
finance-director-resume-examples
fire-safety-officer-resume-sample
fleet-maintenance-manager-resume-samples
format-for-resume-writing
fresher-computer-engineers-resume-sample
fresher-hr-resume-sample
fresher-hr-resume-sample-2
fresher-lecturer-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