SlideShare a Scribd company logo
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

More Related Content

Similar to 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
 
Alberto Paro - Hands on Scala.js
Alberto Paro - Hands on Scala.jsAlberto Paro - Hands on Scala.js
Alberto Paro - Hands on Scala.jsScala Italy
 
Scala Italy 2015 - Hands On ScalaJS
Scala Italy 2015 - Hands On ScalaJSScala Italy 2015 - Hands On ScalaJS
Scala Italy 2015 - Hands On ScalaJSAlberto Paro
 
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
 
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.
 
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
 
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
 

Similar to 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
 
Alberto Paro - Hands on Scala.js
Alberto Paro - Hands on Scala.jsAlberto Paro - Hands on Scala.js
Alberto Paro - Hands on Scala.js
 
Scala Italy 2015 - Hands On ScalaJS
Scala Italy 2015 - Hands On ScalaJSScala Italy 2015 - Hands On ScalaJS
Scala Italy 2015 - Hands On ScalaJS
 
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...
 
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...
 
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...
 
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
 

More from 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
 

More from 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
 

Recently uploaded

BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024Ortus Solutions, Corp
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Globus
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus
 
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdfA Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdfkalichargn70th171
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsGlobus
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageGlobus
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxwottaspaceseo
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyanic lab
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEJelle | Nordend
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfGlobus
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Anthony Dahanne
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Globus
 
AI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAlluxio, Inc.
 
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...rajkumar669520
 
AI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAlluxio, Inc.
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfOrtus Solutions, Corp
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAlluxio, Inc.
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesKrzysztofKkol1
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus
 

Recently uploaded (20)

BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdfA Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
AI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in Michelangelo
 
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
 
AI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning Framework
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 

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

Editor's Notes

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