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/2012
Dimitri de Putte
 
Ionic framework one day training
Ionic framework one day trainingIonic framework one day training
Ionic framework one day training
Troy Miles
 
Intro to .NET for Government Developers
Intro to .NET for Government DevelopersIntro to .NET for Government Developers
Intro to .NET for Government Developers
Frank La Vigne
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
yuvalb
 
Winter '19 release development.ppt
Winter '19 release development.pptWinter '19 release development.ppt
Winter '19 release development.ppt
Kailas Shimpi
 
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
 
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
 
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 Applications
Salesforce 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 Successfully
SpringPeople
 
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
 
ASP.NET - Ivan Marković
ASP.NET - Ivan MarkovićASP.NET - Ivan Marković
ASP.NET - Ivan Marković
Software StartUp Academy Osijek
 
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
 
Mini-Training: Javascript Patterns
Mini-Training: Javascript PatternsMini-Training: Javascript Patterns
Mini-Training: Javascript Patterns
Betclic Everest Group Tech Team
 
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
Salesforce 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 SharePoint
Mark 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 Care
Dmitry 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 Yoga
Dmitry Vinnik
 
Documentation Made Easy with Docusaurus
Documentation Made Easy with DocusaurusDocumentation Made Easy with Docusaurus
Documentation Made Easy with Docusaurus
Dmitry 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 Salesforce
Dmitry 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 Gaps
Dmitry Vinnik
 
Ent: Making Data Easy in Go
Ent: Making Data Easy in GoEnt: Making Data Easy in Go
Ent: Making Data Easy in Go
Dmitry 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 Health
Dmitry 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 Kotlin
Dmitry 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 Hero
Dmitry Vinnik
 
Remote Work: Gateway to Freedom
Remote Work: Gateway to FreedomRemote Work: Gateway to Freedom
Remote Work: Gateway to Freedom
Dmitry Vinnik
 
Kindness Engineering: Focusing on What Matters
Kindness Engineering: Focusing on What MattersKindness Engineering: Focusing on What Matters
Kindness Engineering: Focusing on What Matters
Dmitry Vinnik
 
Gauge + Taiko, BDD for Web Revived
Gauge + Taiko, BDD for Web RevivedGauge + Taiko, BDD for Web Revived
Gauge + Taiko, BDD for Web Revived
Dmitry Vinnik
 
Modern Web Testing: Going Beyond Selenium
Modern Web Testing: Going Beyond SeleniumModern Web Testing: Going Beyond Selenium
Modern Web Testing: Going Beyond Selenium
Dmitry 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 Interfaces
Dmitry 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 It
Dmitry Vinnik
 
Uphill Battle of Mobile Visual Regression
Uphill Battle of Mobile Visual RegressionUphill Battle of Mobile Visual Regression
Uphill Battle of Mobile Visual Regression
Dmitry 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

openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
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
Globus
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
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
 
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
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
Nidhi Software Price. Fact , Costs, Tips
Nidhi Software Price. Fact , Costs, TipsNidhi Software Price. Fact , Costs, Tips
Nidhi Software Price. Fact , Costs, Tips
vrstrong314
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptxText-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
ShamsuddeenMuhammadA
 
Game Development with Unity3D (Game Development lecture 3)
Game Development  with Unity3D (Game Development lecture 3)Game Development  with Unity3D (Game Development lecture 3)
Game Development with Unity3D (Game Development lecture 3)
abdulrafaychaudhry
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 

Recently uploaded (20)

openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
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
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
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...
 
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...
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
Nidhi Software Price. Fact , Costs, Tips
Nidhi Software Price. Fact , Costs, TipsNidhi Software Price. Fact , Costs, Tips
Nidhi Software Price. Fact , Costs, Tips
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptxText-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
 
Game Development with Unity3D (Game Development lecture 3)
Game Development  with Unity3D (Game Development lecture 3)Game Development  with Unity3D (Game Development lecture 3)
Game Development with Unity3D (Game Development lecture 3)
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 

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