SlideShare une entreprise Scribd logo
1  sur  15
Developing Components for
Communities
Tips and Tricks
jamesl@demandchainsystems.com, @dancinllama
James Loghry, Technical Architect and Salesforce MVP
dvinnik@salesforce.com, @dmitryvinnik
Dmitry Vinnik, Senior Software Engineer at Salesforce
Define a Pattern
Define a consistent return type for Apex calls
Use JSON for serializing / deserializing values
Define consistent error and exception handling
Rapid prototyping and development
Use a consistent pattern across your components and Apex
2
Define a Pattern
public with sharing class MyLightningCtrl{
@AuraEnabled
public static LightningResponse doAction() {
LightningResponse response = new LightningResponse();
try{
//do stuff, perhaps throw an exception.
User u = [Select Id From User];
response.jsonResponse = JSON.serialize(u);
}catch(Exception e){
response = new LightningResponse(e);
}
return response;
}
}
Use a consistent pattern across Apex and Lightning
public class LightningResponse{
@AuraEnabled public String jsonResponse {get;set;}
@AuraEnabled public String errorMessage {get;set;}
@AuraEnabled public String state {get;set;}
public LightningResponse() {
this.state = 'SUCCESS';
}
public LightningResponse(Exception e){
this();
if(e != null){
this.state = 'ERROR';
this.errorMessage = e.getMessage();
//Log error to a custom object here
}
}
}
3
Use Abstract Components
Reuse Logic
• Enqueueing apex actions
• Callbacks
Define consistent error and exception handling
• Display toast messages on errors
Utility Functions
• Show toasts
• Display spinners
• Sorting
({
handleAction : function(component, actionParams, actionName, successCallback, errorCallback){
var action = component.get(actionName);
action.setParams(actionParams);
var self = this;
action.setCallback(self,function(a){
try{
if(a.getState() !== ‘SUCCESS'){
//handle error
}
var result = a.getReturnValue();
//Some error likely inside of the Apex code occurred.
if(result.state !== 'SUCCESS'){
//Try to get the error message from the lightningdmlerror object
var errorEncountered = result.errorMe;
throw {
'message' : 'An error occurred in the apex call',
'extendedMessage' : result.errorMessage
};
}
var returnValue = undefined;
if(!$A.util.isEmpty(result.jsonResponse)){
//Will throw a JSON exception if the result cannot be parsed.
returnValue = JSON.parse(result.jsonResponse);
}
var concreteComponent = component.getConcreteComponent();
successCallback(concreteComponent,returnValue, self);
}catch(ex){
//handleError
}
});
$A.enqueueAction(action);
}
Reuse logic, improve code readability and maintainability with abstract components
4
Power to the Admin!
Design Tokens
Design Attributes
Allow admins to configure components with community builder
5
Power to the Admin!
Tokens are CSS variables used for styling
components
Using standard design tokens allow admins to
update your components’ branding.
Custom design tokens can utilize and expand
upon standard custom tokens
//Component.css
.THIS .iconStyle{
background-color: token(inverseText) !important;
}
.THIS .iconStyle svg{
fill: token(inverseText);
background-color: token(inverseBackground);
}
Empower admins with design tokens
6
Power to the Admin!
Allow admins to configure components through design attributes
Admins can control:
• Text and labels
• Number of records displayed
• Filters
• Component Layout
Style and configure components with clicks, not code.
Empower with design attributes
7
Debugging Lightning Components
How, What, Why is my component not working properly?
Errors happen for a variety of reasons
• Syntax errors
• Bad data
• API Version mismatch in component
• Javascript controllers / helpers with same method name as Apex
• Browser inconsistencies
When issues arise
8
Debugging Lightning Components
Component is missing from
community
• Open community builder, and
look for errors.
• Try removing and re-adding the
component in community
builder
• Run the Lightning Linter against
your components
Non descript errors
• Check API versions of the
component bundles
• Check method names of
Javascript and Apex
• Try re-saving the Apex or
Lightning component, looking
for modified code or conflicts.
• Run the Lightning Linter against
your components
Cannot add component to
community or cannot use
component as custom theme or
profile.
• Check the interface that the
component is using.
Missing data
• Add breakpoints to component
through JavaScript console /
developer tools in browser.
• Look at sharing permissions of
Apex classes and associated
objects
• Create a debug log in Salesforce
How to diagnose issues
9
Debugging Lightning Components
Developer Tools / Javascript Console
• Chrome Developer Tools
• Safari Javascript Console
• Firefox JavaScript debugger
Lightning Linter
• CLI / Heroku Toolbelt
• IDEs
Salesforce DX
• Scratch orgs
Lightning Test Service
• Unit testing for Lightning Components
Tools of the trade
10
Demo
Embracing SEO
Link Juice (Internal Hyperlinking)
• Allows Search Bots to rank pages
• Use routeLink.cmp to auto-generate HREF
Link Targeting with Sitemap
• Auto-generated on a daily basis
• Uses all publicly exposed pages
Controlling Searchable Content
• Avoid duplicate content
• Adjust FLS to allow for data crawling
cmp.
<aura:component implements="forceCommunity:availableForAllPageTypes">
<aura:attribute name="recordId" type="String" default="{!v.recordId}" />
<aura:attribute name="routeInput" type="Map"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<forceCommunity:routeLink title="My Case" routeInput="{!v.routeInput}" />
</aura:component>
.js
({
doInit : function(component, event, helper) {
component.set('v.routeInput', { recordId: component.get('v.recordId')});
}
})
Output:
<a href="/myCommunity/s/case/500xx000000YkvU/mycase” title="My Case”/>
Enhance your community’s search results by embracing components’ SEO capabilities
12
Explore all of the Community Cloud Developer Sessions
An Introduction to Lightning Communities
& Community Builder
• Wed, 1:30 – 1:50pm @ Ridge Theatre
Developing Performant Lightning
Communities For B2B and B2C Scale
• Tues, 10:30 – 11:10am @ Room 2007
Develop Visually Stunning & Personalized
Lightning Communities
• Tues, 4:30 – 5:10pm @ Room 2007
• Wed, 1:30 – 2:10pm @ Room 2007
How to Build Rich Publisher Apps w/
Chatter
• Mon, 10:30 – 10:50am @ Frontier Theatre
Mastering Lightning Community
Development
• Tues, 9:00 – 9:40am @ Room 2009
• Wed, 4:00 – 4:40pm @ Room 2006
Q&A with the Architects Behind
Community Cloud
• Mon, 1:45 – 2:05pm @ Developer Theatre
Tips and Tricks for Developing
Components for Communities
• Mon, 9:30 – 9:50am @ Frontier Theatre
• Wed, 2:30 – 2:50pm @ Frontier Theatre
Communities Trailmix
http://sforce.co/2g35A3G
Deploy with DX
http://bit.ly/2x9iYNY
Salesforce Docs
http://sforce.co/2yRwALg
Developing Lightning Components for Communities.pptx

Contenu connexe

Similaire à Developing Lightning Components for Communities.pptx

Backbonification for dummies - Arrrrug 10/1/2012
Backbonification for dummies - Arrrrug 10/1/2012Backbonification for dummies - Arrrrug 10/1/2012
Backbonification for dummies - Arrrrug 10/1/2012Dimitri de Putte
 
Ionic framework one day training
Ionic framework one day trainingIonic framework one day training
Ionic framework one day trainingTroy Miles
 
Intro to .NET for Government Developers
Intro to .NET for Government DevelopersIntro to .NET for Government Developers
Intro to .NET for Government DevelopersFrank La Vigne
 
Spring MVC
Spring MVCSpring MVC
Spring MVCyuvalb
 
Winter '19 release development.ppt
Winter '19 release development.pptWinter '19 release development.ppt
Winter '19 release development.pptKailas Shimpi
 
Scala Italy 2015 - Hands On ScalaJS
Scala Italy 2015 - Hands On ScalaJSScala Italy 2015 - Hands On ScalaJS
Scala Italy 2015 - Hands On ScalaJSAlberto Paro
 
Alberto Paro - Hands on Scala.js
Alberto Paro - Hands on Scala.jsAlberto Paro - Hands on Scala.js
Alberto Paro - Hands on Scala.jsScala Italy
 
SharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentialsSharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentialsMark Rackley
 
Lightning web components
Lightning web components Lightning web components
Lightning web components Cloud Analogy
 
Javascript-heavy Salesforce Applications
Javascript-heavy Salesforce ApplicationsJavascript-heavy Salesforce Applications
Javascript-heavy Salesforce ApplicationsSalesforce Developers
 
RightScale API: How To Build Your Own IT Vending Machine - RightScale Compute...
RightScale API: How To Build Your Own IT Vending Machine - RightScale Compute...RightScale API: How To Build Your Own IT Vending Machine - RightScale Compute...
RightScale API: How To Build Your Own IT Vending Machine - RightScale Compute...RightScale
 
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...Malin Weiss
 
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...Speedment, Inc.
 
Mastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullyMastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullySpringPeople
 
Intro to Salesforce Lightning Web Components (LWC)
Intro to Salesforce Lightning Web Components (LWC)Intro to Salesforce Lightning Web Components (LWC)
Intro to Salesforce Lightning Web Components (LWC)Roy Gilad
 
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...Codemotion
 
Apex Code Analysis Using the Tooling API and Canvas
Apex Code Analysis Using the Tooling API and CanvasApex Code Analysis Using the Tooling API and Canvas
Apex Code Analysis Using the Tooling API and CanvasSalesforce Developers
 
SPTechCon 2014 How to develop and debug client side code in SharePoint
SPTechCon 2014 How to develop and debug client side code in SharePointSPTechCon 2014 How to develop and debug client side code in SharePoint
SPTechCon 2014 How to develop and debug client side code in SharePointMark Rackley
 

Similaire à Developing Lightning Components for Communities.pptx (20)

Backbonification for dummies - Arrrrug 10/1/2012
Backbonification for dummies - Arrrrug 10/1/2012Backbonification for dummies - Arrrrug 10/1/2012
Backbonification for dummies - Arrrrug 10/1/2012
 
Ionic framework one day training
Ionic framework one day trainingIonic framework one day training
Ionic framework one day training
 
Intro to .NET for Government Developers
Intro to .NET for Government DevelopersIntro to .NET for Government Developers
Intro to .NET for Government Developers
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
 
Winter '19 release development.ppt
Winter '19 release development.pptWinter '19 release development.ppt
Winter '19 release development.ppt
 
Scala Italy 2015 - Hands On ScalaJS
Scala Italy 2015 - Hands On ScalaJSScala Italy 2015 - Hands On ScalaJS
Scala Italy 2015 - Hands On ScalaJS
 
Alberto Paro - Hands on Scala.js
Alberto Paro - Hands on Scala.jsAlberto Paro - Hands on Scala.js
Alberto Paro - Hands on Scala.js
 
SharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentialsSharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentials
 
Lightning web components
Lightning web components Lightning web components
Lightning web components
 
Javascript-heavy Salesforce Applications
Javascript-heavy Salesforce ApplicationsJavascript-heavy Salesforce Applications
Javascript-heavy Salesforce Applications
 
RightScale API: How To Build Your Own IT Vending Machine - RightScale Compute...
RightScale API: How To Build Your Own IT Vending Machine - RightScale Compute...RightScale API: How To Build Your Own IT Vending Machine - RightScale Compute...
RightScale API: How To Build Your Own IT Vending Machine - RightScale Compute...
 
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
 
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
 
Mastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullyMastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium Successfully
 
Intro to Salesforce Lightning Web Components (LWC)
Intro to Salesforce Lightning Web Components (LWC)Intro to Salesforce Lightning Web Components (LWC)
Intro to Salesforce Lightning Web Components (LWC)
 
ASP.NET - Ivan Marković
ASP.NET - Ivan MarkovićASP.NET - Ivan Marković
ASP.NET - Ivan Marković
 
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
 
Mini-Training: Javascript Patterns
Mini-Training: Javascript PatternsMini-Training: Javascript Patterns
Mini-Training: Javascript Patterns
 
Apex Code Analysis Using the Tooling API and Canvas
Apex Code Analysis Using the Tooling API and CanvasApex Code Analysis Using the Tooling API and Canvas
Apex Code Analysis Using the Tooling API and Canvas
 
SPTechCon 2014 How to develop and debug client side code in SharePoint
SPTechCon 2014 How to develop and debug client side code in SharePointSPTechCon 2014 How to develop and debug client side code in SharePoint
SPTechCon 2014 How to develop and debug client side code in SharePoint
 

Plus de Dmitry Vinnik

Leadership in Open Source and Why Companies Care
Leadership in Open Source and Why Companies CareLeadership in Open Source and Why Companies Care
Leadership in Open Source and Why Companies CareDmitry Vinnik
 
Maximizing React Speed: Hands-On Guide to Debugging and Optimizing React Appl...
Maximizing React Speed: Hands-On Guide to Debugging and Optimizing React Appl...Maximizing React Speed: Hands-On Guide to Debugging and Optimizing React Appl...
Maximizing React Speed: Hands-On Guide to Debugging and Optimizing React Appl...Dmitry Vinnik
 
Testing React with Jest: Validate Your Components Quickly!
Testing React with Jest: Validate Your Components Quickly!Testing React with Jest: Validate Your Components Quickly!
Testing React with Jest: Validate Your Components Quickly!Dmitry Vinnik
 
Cross-Platform CSS (Yes, it's Possible!) with Yoga
Cross-Platform CSS (Yes, it's Possible!) with YogaCross-Platform CSS (Yes, it's Possible!) with Yoga
Cross-Platform CSS (Yes, it's Possible!) with YogaDmitry Vinnik
 
Documentation Made Easy with Docusaurus
Documentation Made Easy with DocusaurusDocumentation Made Easy with Docusaurus
Documentation Made Easy with DocusaurusDmitry Vinnik
 
Testing at Scale at Meta and Salesforce
Testing at Scale at Meta and SalesforceTesting at Scale at Meta and Salesforce
Testing at Scale at Meta and SalesforceDmitry Vinnik
 
Fixing Broken Windows: Dealing with Legacy Systems, Poor Quality and Gaps
Fixing Broken Windows: Dealing with Legacy Systems, Poor Quality and GapsFixing Broken Windows: Dealing with Legacy Systems, Poor Quality and Gaps
Fixing Broken Windows: Dealing with Legacy Systems, Poor Quality and GapsDmitry Vinnik
 
Ent: Making Data Easy in Go
Ent: Making Data Easy in GoEnt: Making Data Easy in Go
Ent: Making Data Easy in GoDmitry Vinnik
 
The 10,000 Steps of Open Source Project Health
The 10,000 Steps of Open Source Project HealthThe 10,000 Steps of Open Source Project Health
The 10,000 Steps of Open Source Project HealthDmitry Vinnik
 
Better Start: Enforcing Best Engineering Practices with Kotlin
Better Start: Enforcing Best Engineering Practices with KotlinBetter Start: Enforcing Best Engineering Practices with Kotlin
Better Start: Enforcing Best Engineering Practices with KotlinDmitry Vinnik
 
Testing Svelte with Jest: Validate Your Components Quickly!
Testing Svelte with Jest: Validate Your Components Quickly!Testing Svelte with Jest: Validate Your Components Quickly!
Testing Svelte with Jest: Validate Your Components Quickly!Dmitry Vinnik
 
Hands on React Native: From Zero to Hero
Hands on React  Native:  From Zero to HeroHands on React  Native:  From Zero to Hero
Hands on React Native: From Zero to HeroDmitry Vinnik
 
Remote Work: Gateway to Freedom
Remote Work: Gateway to FreedomRemote Work: Gateway to Freedom
Remote Work: Gateway to FreedomDmitry Vinnik
 
Kindness Engineering: Focusing on What Matters
Kindness Engineering: Focusing on What MattersKindness Engineering: Focusing on What Matters
Kindness Engineering: Focusing on What MattersDmitry Vinnik
 
Gauge + Taiko, BDD for Web Revived
Gauge + Taiko, BDD for Web RevivedGauge + Taiko, BDD for Web Revived
Gauge + Taiko, BDD for Web RevivedDmitry Vinnik
 
Modern Web Testing: Going Beyond Selenium
Modern Web Testing: Going Beyond SeleniumModern Web Testing: Going Beyond Selenium
Modern Web Testing: Going Beyond SeleniumDmitry Vinnik
 
Do you even Function? Guiding Through Functional Interfaces
Do you even Function? Guiding Through Functional InterfacesDo you even Function? Guiding Through Functional Interfaces
Do you even Function? Guiding Through Functional InterfacesDmitry Vinnik
 
From Robotium to Appium: Choose your Journey
From Robotium to Appium: Choose your Journey From Robotium to Appium: Choose your Journey
From Robotium to Appium: Choose your Journey Dmitry Vinnik
 
Stress Driven Development, and How to Avoid It
Stress Driven Development, and How to Avoid ItStress Driven Development, and How to Avoid It
Stress Driven Development, and How to Avoid ItDmitry Vinnik
 
Uphill Battle of Mobile Visual Regression
Uphill Battle of Mobile Visual RegressionUphill Battle of Mobile Visual Regression
Uphill Battle of Mobile Visual RegressionDmitry Vinnik
 

Plus de Dmitry Vinnik (20)

Leadership in Open Source and Why Companies Care
Leadership in Open Source and Why Companies CareLeadership in Open Source and Why Companies Care
Leadership in Open Source and Why Companies Care
 
Maximizing React Speed: Hands-On Guide to Debugging and Optimizing React Appl...
Maximizing React Speed: Hands-On Guide to Debugging and Optimizing React Appl...Maximizing React Speed: Hands-On Guide to Debugging and Optimizing React Appl...
Maximizing React Speed: Hands-On Guide to Debugging and Optimizing React Appl...
 
Testing React with Jest: Validate Your Components Quickly!
Testing React with Jest: Validate Your Components Quickly!Testing React with Jest: Validate Your Components Quickly!
Testing React with Jest: Validate Your Components Quickly!
 
Cross-Platform CSS (Yes, it's Possible!) with Yoga
Cross-Platform CSS (Yes, it's Possible!) with YogaCross-Platform CSS (Yes, it's Possible!) with Yoga
Cross-Platform CSS (Yes, it's Possible!) with Yoga
 
Documentation Made Easy with Docusaurus
Documentation Made Easy with DocusaurusDocumentation Made Easy with Docusaurus
Documentation Made Easy with Docusaurus
 
Testing at Scale at Meta and Salesforce
Testing at Scale at Meta and SalesforceTesting at Scale at Meta and Salesforce
Testing at Scale at Meta and Salesforce
 
Fixing Broken Windows: Dealing with Legacy Systems, Poor Quality and Gaps
Fixing Broken Windows: Dealing with Legacy Systems, Poor Quality and GapsFixing Broken Windows: Dealing with Legacy Systems, Poor Quality and Gaps
Fixing Broken Windows: Dealing with Legacy Systems, Poor Quality and Gaps
 
Ent: Making Data Easy in Go
Ent: Making Data Easy in GoEnt: Making Data Easy in Go
Ent: Making Data Easy in Go
 
The 10,000 Steps of Open Source Project Health
The 10,000 Steps of Open Source Project HealthThe 10,000 Steps of Open Source Project Health
The 10,000 Steps of Open Source Project Health
 
Better Start: Enforcing Best Engineering Practices with Kotlin
Better Start: Enforcing Best Engineering Practices with KotlinBetter Start: Enforcing Best Engineering Practices with Kotlin
Better Start: Enforcing Best Engineering Practices with Kotlin
 
Testing Svelte with Jest: Validate Your Components Quickly!
Testing Svelte with Jest: Validate Your Components Quickly!Testing Svelte with Jest: Validate Your Components Quickly!
Testing Svelte with Jest: Validate Your Components Quickly!
 
Hands on React Native: From Zero to Hero
Hands on React  Native:  From Zero to HeroHands on React  Native:  From Zero to Hero
Hands on React Native: From Zero to Hero
 
Remote Work: Gateway to Freedom
Remote Work: Gateway to FreedomRemote Work: Gateway to Freedom
Remote Work: Gateway to Freedom
 
Kindness Engineering: Focusing on What Matters
Kindness Engineering: Focusing on What MattersKindness Engineering: Focusing on What Matters
Kindness Engineering: Focusing on What Matters
 
Gauge + Taiko, BDD for Web Revived
Gauge + Taiko, BDD for Web RevivedGauge + Taiko, BDD for Web Revived
Gauge + Taiko, BDD for Web Revived
 
Modern Web Testing: Going Beyond Selenium
Modern Web Testing: Going Beyond SeleniumModern Web Testing: Going Beyond Selenium
Modern Web Testing: Going Beyond Selenium
 
Do you even Function? Guiding Through Functional Interfaces
Do you even Function? Guiding Through Functional InterfacesDo you even Function? Guiding Through Functional Interfaces
Do you even Function? Guiding Through Functional Interfaces
 
From Robotium to Appium: Choose your Journey
From Robotium to Appium: Choose your Journey From Robotium to Appium: Choose your Journey
From Robotium to Appium: Choose your Journey
 
Stress Driven Development, and How to Avoid It
Stress Driven Development, and How to Avoid ItStress Driven Development, and How to Avoid It
Stress Driven Development, and How to Avoid It
 
Uphill Battle of Mobile Visual Regression
Uphill Battle of Mobile Visual RegressionUphill Battle of Mobile Visual Regression
Uphill Battle of Mobile Visual Regression
 

Dernier

Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
cpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptcpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptrcbcrtm
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 

Dernier (20)

Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
cpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptcpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.ppt
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 

Developing Lightning Components for Communities.pptx

  • 1. Developing Components for Communities Tips and Tricks jamesl@demandchainsystems.com, @dancinllama James Loghry, Technical Architect and Salesforce MVP dvinnik@salesforce.com, @dmitryvinnik Dmitry Vinnik, Senior Software Engineer at Salesforce
  • 2. Define a Pattern Define a consistent return type for Apex calls Use JSON for serializing / deserializing values Define consistent error and exception handling Rapid prototyping and development Use a consistent pattern across your components and Apex 2
  • 3. Define a Pattern public with sharing class MyLightningCtrl{ @AuraEnabled public static LightningResponse doAction() { LightningResponse response = new LightningResponse(); try{ //do stuff, perhaps throw an exception. User u = [Select Id From User]; response.jsonResponse = JSON.serialize(u); }catch(Exception e){ response = new LightningResponse(e); } return response; } } Use a consistent pattern across Apex and Lightning public class LightningResponse{ @AuraEnabled public String jsonResponse {get;set;} @AuraEnabled public String errorMessage {get;set;} @AuraEnabled public String state {get;set;} public LightningResponse() { this.state = 'SUCCESS'; } public LightningResponse(Exception e){ this(); if(e != null){ this.state = 'ERROR'; this.errorMessage = e.getMessage(); //Log error to a custom object here } } } 3
  • 4. Use Abstract Components Reuse Logic • Enqueueing apex actions • Callbacks Define consistent error and exception handling • Display toast messages on errors Utility Functions • Show toasts • Display spinners • Sorting ({ handleAction : function(component, actionParams, actionName, successCallback, errorCallback){ var action = component.get(actionName); action.setParams(actionParams); var self = this; action.setCallback(self,function(a){ try{ if(a.getState() !== ‘SUCCESS'){ //handle error } var result = a.getReturnValue(); //Some error likely inside of the Apex code occurred. if(result.state !== 'SUCCESS'){ //Try to get the error message from the lightningdmlerror object var errorEncountered = result.errorMe; throw { 'message' : 'An error occurred in the apex call', 'extendedMessage' : result.errorMessage }; } var returnValue = undefined; if(!$A.util.isEmpty(result.jsonResponse)){ //Will throw a JSON exception if the result cannot be parsed. returnValue = JSON.parse(result.jsonResponse); } var concreteComponent = component.getConcreteComponent(); successCallback(concreteComponent,returnValue, self); }catch(ex){ //handleError } }); $A.enqueueAction(action); } Reuse logic, improve code readability and maintainability with abstract components 4
  • 5. Power to the Admin! Design Tokens Design Attributes Allow admins to configure components with community builder 5
  • 6. Power to the Admin! Tokens are CSS variables used for styling components Using standard design tokens allow admins to update your components’ branding. Custom design tokens can utilize and expand upon standard custom tokens //Component.css .THIS .iconStyle{ background-color: token(inverseText) !important; } .THIS .iconStyle svg{ fill: token(inverseText); background-color: token(inverseBackground); } Empower admins with design tokens 6
  • 7. Power to the Admin! Allow admins to configure components through design attributes Admins can control: • Text and labels • Number of records displayed • Filters • Component Layout Style and configure components with clicks, not code. Empower with design attributes 7
  • 8. Debugging Lightning Components How, What, Why is my component not working properly? Errors happen for a variety of reasons • Syntax errors • Bad data • API Version mismatch in component • Javascript controllers / helpers with same method name as Apex • Browser inconsistencies When issues arise 8
  • 9. Debugging Lightning Components Component is missing from community • Open community builder, and look for errors. • Try removing and re-adding the component in community builder • Run the Lightning Linter against your components Non descript errors • Check API versions of the component bundles • Check method names of Javascript and Apex • Try re-saving the Apex or Lightning component, looking for modified code or conflicts. • Run the Lightning Linter against your components Cannot add component to community or cannot use component as custom theme or profile. • Check the interface that the component is using. Missing data • Add breakpoints to component through JavaScript console / developer tools in browser. • Look at sharing permissions of Apex classes and associated objects • Create a debug log in Salesforce How to diagnose issues 9
  • 10. Debugging Lightning Components Developer Tools / Javascript Console • Chrome Developer Tools • Safari Javascript Console • Firefox JavaScript debugger Lightning Linter • CLI / Heroku Toolbelt • IDEs Salesforce DX • Scratch orgs Lightning Test Service • Unit testing for Lightning Components Tools of the trade 10
  • 11. Demo
  • 12. Embracing SEO Link Juice (Internal Hyperlinking) • Allows Search Bots to rank pages • Use routeLink.cmp to auto-generate HREF Link Targeting with Sitemap • Auto-generated on a daily basis • Uses all publicly exposed pages Controlling Searchable Content • Avoid duplicate content • Adjust FLS to allow for data crawling cmp. <aura:component implements="forceCommunity:availableForAllPageTypes"> <aura:attribute name="recordId" type="String" default="{!v.recordId}" /> <aura:attribute name="routeInput" type="Map"/> <aura:handler name="init" value="{!this}" action="{!c.doInit}"/> <forceCommunity:routeLink title="My Case" routeInput="{!v.routeInput}" /> </aura:component> .js ({ doInit : function(component, event, helper) { component.set('v.routeInput', { recordId: component.get('v.recordId')}); } }) Output: <a href="/myCommunity/s/case/500xx000000YkvU/mycase” title="My Case”/> Enhance your community’s search results by embracing components’ SEO capabilities 12
  • 13. Explore all of the Community Cloud Developer Sessions An Introduction to Lightning Communities & Community Builder • Wed, 1:30 – 1:50pm @ Ridge Theatre Developing Performant Lightning Communities For B2B and B2C Scale • Tues, 10:30 – 11:10am @ Room 2007 Develop Visually Stunning & Personalized Lightning Communities • Tues, 4:30 – 5:10pm @ Room 2007 • Wed, 1:30 – 2:10pm @ Room 2007 How to Build Rich Publisher Apps w/ Chatter • Mon, 10:30 – 10:50am @ Frontier Theatre Mastering Lightning Community Development • Tues, 9:00 – 9:40am @ Room 2009 • Wed, 4:00 – 4:40pm @ Room 2006 Q&A with the Architects Behind Community Cloud • Mon, 1:45 – 2:05pm @ Developer Theatre Tips and Tricks for Developing Components for Communities • Mon, 9:30 – 9:50am @ Frontier Theatre • Wed, 2:30 – 2:50pm @ Frontier Theatre
  • 14. Communities Trailmix http://sforce.co/2g35A3G Deploy with DX http://bit.ly/2x9iYNY Salesforce Docs http://sforce.co/2yRwALg

Notes de l'éditeur

  1. Mike - Connect with Employees, Customers, Partners, Integrated with the Org Viswa - Various standard components Yad - Custom Components Vishwa - Deployment options