SlideShare uma empresa Scribd logo
1 de 24
Baixar para ler offline
ACCENTURE
TECHNOLOGY
MEETUP
A GENERIC RELATED
LIST IN LIGHTNING
WEB COMPONENT
Laura Fulmer
Salesforce Developer
ABOUT THE PRESENTER
Laura Fulmer
laura.fulmer@accenture.com
Salesforce Developer
Certifications:
– Platform App Builder
– Platform Developer I
– Einstein Analytics and Discovery Consultant
AGENDA
Copyright © 2020 Accenture. All rights reserved. 3
About the LWC
• What are these components?
• Aura vs. LWC
• Parts of the package
• Advantages and considerations
Demo
• Wrapper Class
• Dynamic query
• Flatten the object structure
• Grouping and Concatenating
WHAT ARE LIGHTNING WEB
COMPONENTS?
Copyright © 2020 Accenture. All rights reserved. 4
• A new programming model for building Lightning components
that leverages the web standards breakthroughs of 2014-2019
• LWC is an implementation of the W3C’s Web Components
standards
• Provides a layer of specialized Salesforce services on top of the
core stack
• Can coexist and interoperate with the Aura model
• Unparalleled performance
AURA VS. LWC
Copyright © 2020 Accenture. All rights reserved. 5
• Aura and LWC components can coexist
and interoperate in the same org and
on same page
• They can share the same
– Underlying services
– Base Lightning components
– High leves services
• Aura can include LWC but LWC cannot
include Aura
Lightning Components
Security
Lightning Data Service
Base Lightning Components
Custom component
model
Custom components
Rendering optimization
Custom modules
Custom events
Web components
Templates
Custom elements
Shadow DOM
Modules
Standard events
Events
Standard elements
Rendering
ECMAScript 5 ECMAScript 7
Aura
Programming Model
Lightning Web Components
Programming Model
AURA VS. LWC
FILE MAPPING IN THE COMPONENT BUNDLE
Copyright © 2020 Accenture. All rights reserved. 6
Copyright © 2020 Accenture. All rights reserved. 7
CONFIGURATION FILE
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>48.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__RecordPage</target>
<objects>
<object>Account</object>
</objects>
<target>lightning__HomePage</target>
</targets>
<targetConfigs>
<targetConfig targets="lightning__RecordPage, lightning__HomePage">
<property name="subject" type="String" default=""
label="Name of the person you want to greet"/>
<property name="greeting" type="String" default="" label="Greeting" />
</targetConfig>
</targetConfigs>
</LightningComponentBundle>
<design:component label="Hello World">
<design:attribute name="subject" label="Subject"
description="Name of the person you want to greet" />
<design:attribute name="greeting" label="Greeting" />
</design:component>
LWC Aura
Copyright © 2020 Accenture. All rights reserved. 8
JAVASCRIPT
({
count : function(component, event, helper){
let greeting = component.get("v.greeting");
alert(greeting.length + " letters");
}
})
import { LightningElement, track } from 'lwc';
export default class HelloLwc extends LightningElement {
@track greeting = 'World';
handleChange(event){
this.greetig = event.target.value;
}
count(){
alert(this.greeting.length + " letters");
}
}
LWC Aura
Copyright © 2020 Accenture. All rights reserved. 9
HTML
<template>
<lightning-card title="Hello_LWC">
<lightning-button label="count" onclick={count}>
</lightning-button>
<div class="slds-m-around_medium">
<p>Hello, {greeting}!</p>
<lightning-input label="Name" value={greeting}
onchange={handlechange}>
</lightning-input>
</div>
</lightning-card>
</template>
<aura:component
implements="flexipage:availableForAllPageTypes"
access="global">
<aura:attribute name="greeting" type="String">
<lightning:card title="Hello_Aura">
<aura:set attribute="actions">
<lightning:button label="count" onclick="{!c.count}"/>
</aura:set>
<div class="slds-m-around_medium">
<p>Hello, {!v.greeting}!</p>
<lightning:input label="Name" value="{!v.greeting}"/>
</div>
</lightning:card>
</aura:component>
LWC Aura
Copyright © 2020 Accenture. All rights reserved. 10
CSS
• No need for .THIS
• Standard CSS syntax
• To override lightning design use
loadStyle and static resource
• CSS styles defined in a parent
component don’t reach into a child.
.boxLarge {
width: 200px;
height: 200px;
border: 1px solid red;
background-color: #344A5F;
}
.boxSmall {
width: 100px;
height: 100px;
margin: auto;
background-color: #F0F1F2;
}
Copyright © 2020 Accenture. All rights reserved. 11
LIFECYCLE HOOKS
constructor() called parent
connectedCallback() called
on parent
render() called parent
renderedCallback() called on
parent
constructor() called on child
connectedCallback() called
on child
render() called on child
renderedCallback() called on
child
Properties
assigned
Parent Component Child Component
1
2
3
8 7
6
5
4
Properties
assigned
Parent created
12Copyright © 2020 Accenture. All rights reserved.
ADVANTAGES OF THE LWC
BETTER
PERFORMANCE
Faster loading sites
MORE STANDARD
Built-in browser security
features, more out-of-
the-box solutions and
less customization
BETTER BROWSER
COMPATIBILITY
More consistency
SERVICE
COMPONENT
More reusable and
efficient components
without UI elements
EASY TO LEARN
Based on native web
standards, no added
abstraction layer
13Copyright © 2020 Accenture. All rights reserved.
CONSIDERATIONS OF THE
USAGE OF LWC
UNSUPPORTED
EXPERIENCES AND
TOOLS
APIs, Actions and
Chatter extension
MOBILE SDK DOESN’T
SUPPORT IT
Wrapping it in Aura is
also unsupported
CANNOT CONTAIN
AURA
This needs to be
considered upon
planning
DEMO
OBJECT STRUCTURE
Copyright © 2020 Accenture. All rights reserved. 15
ContactLead
Reservation__c
Market__c Space__c
The dynamic query is built on the information from the Admin user
SELECT [Field Set name] FROM [Child object API name]
WHERE [Parent field API name on child object] = recordId
AND [Additional filter in SOQL format]
SORT BY [API name of the field that is the base of sorting]
[Sort Direction]
DYNAMIC QUERY
Copyright © 2020 Accenture. All rights reserved. 16
Copyright © 2020 Accenture. All rights reserved. 17
public class lightningTableColumnWrapper {
@AuraEnabled
public string label {get;set;}
@AuraEnabled
public String fieldName {get;set;}
@AuraEnabled
public string type {get;set;}
@AuraEnabled
public boolean sortable {get;set;}
}
WRAPPER CLASS
public class lightningTableWrapper{
@AuraEnabled
public List<sObject>
tableRecord {get;set;}
@AuraEnabled
public List<lightningTableColumnWrapper>
tableColumn {get;set;}
@AuraEnabled
public Map<String,String>
referenceValMap{get;set;}
}
Copyright © 2020 Accenture. All rights reserved. 18
FLATTEN THE OBJECT STRUCTURE FOR THE
DATATABLE I
Copyright © 2020 Accenture. All rights reserved. 19
changeIdToName(output) {
for (let i = 0; i < this.totalCount; i++) {
let currentObject = {};
Object.assign(currentObject, this.resp.tableRecord[i]);
currentObject.Id = '/' + currentObject.Id;
for (let j = 0; j < Object.keys(currentObject).length; j++) {
let currentField = Object.keys(currentObject)[j];
if (typeof currentObject[currentField] === 'object') {
const newVal = currentObject[currentField].Id ? ('/' + currentObject[currentField].Id) : null;
this.flattenStructure(currentObject, currentField + '_', currentObject[currentField]);
currentObject[currentField] = newVal;
}
}
output.push(currentObject);
}
}
FLATTEN THE OBJECT STRUCTURE FOR THE
DATATABLE II
flattenStructure(topObject, prefix, toBeFlattened) {
// eslint-disable-next-line guard-for-in
for (const prop in toBeFlattened) {
const curVal = toBeFlattened[prop];
if (typeof curVal === 'object') {
this.flattenStructure(topObject, prefix + prop + '_', curVal);
} else {
topObject[prefix + prop] = curVal;
}
}
}
Copyright © 2020 Accenture. All rights reserved. 20
groupFields(output) {
let groups = {};
let groupField = this.groupBy;
groups = output.reduce(function (initialValue, currentValue) {
initialValue[currentValue[groupField]] = initialValue[currentValue[groupField]] || [];
let currentRecord = {};
Object.assign(currentRecord, currentValue);
initialValue[currentValue[groupField]].push(currentRecord);
return initialValue;
}, Object.create(null));
return groups;
}
GROUPING FIELDS
Copyright © 2020 Accenture. All rights reserved. 21
concatenateFields(groups, cols) {
let concatArray = [];
for (let i = 0; i < Object.keys(groups).length; i++) {
this.totalCount = Object.keys(groups).length;
let currentGroupName = Object.keys(groups)[i];
let currentGroup = groups[currentGroupName];
//Looping over the columns of the current group
for (let j = 0; j < cols.length; j++) {
let currentField = cols[j].fieldName;
//Looping over the records of the current group
for (let l = 0; l < currentGroup.length; l++) {
//If the value in the first line is undefined, make it equal with the
current value
if (currentGroup[0][currentField] === undefined) {
currentGroup[0][currentField] = currentGroup[l][currentField];
}
CONCATENATE VALUES
//If the current value is NOT undefined or the first value does not
contain it, concatenate it to the first one
if (currentGroup[l][currentField] !== undefined
&& !currentGroup[0][currentField]
.includes(currentGroup[l][currentField])) {
currentGroup[0][currentField] +=
', ' + currentGroup[l][currentField];
}
}
}
concatArray.push(currentGroup[0]);
}
return concatArray;
}
Q&A
THANK YOU
FOR YOUR
ATTENTION!
USEFUL LINKS
Copyright © 2020 Accenture. All rights reserved. 24
Component Reference:
developer.salesforce.com/docs/component-library/overview/components
LWC sample apps:
trailhead.salesforce.com/sample-gallery
Salesforce Lightning Design System:
lightningdesignsystem.com
Supported Salesforce experiences and tools in LWC:
developer.salesforce.com/docs/component-
library/documentation/en/lwc/lwc.get_started_supported_experiences
Open source base components:
github.com/salesforce/base-components-recipes

Mais conteúdo relacionado

Mais procurados

Lecture Slides for List Views [Android ]
Lecture Slides for List Views [Android ]Lecture Slides for List Views [Android ]
Lecture Slides for List Views [Android ]
Nehil Jain
 

Mais procurados (12)

CData Power BI Connectors
CData Power BI ConnectorsCData Power BI Connectors
CData Power BI Connectors
 
Big Objects in Salesforce
Big Objects in SalesforceBig Objects in Salesforce
Big Objects in Salesforce
 
Quickly Create Data Sets for the Analytics Cloud
Quickly Create Data Sets for the Analytics CloudQuickly Create Data Sets for the Analytics Cloud
Quickly Create Data Sets for the Analytics Cloud
 
Summer - The HTML5 Library for Java and Scala
Summer - The HTML5 Library for Java and ScalaSummer - The HTML5 Library for Java and Scala
Summer - The HTML5 Library for Java and Scala
 
#SalesforceSaturday : Salesforce BIG Objects Explained
#SalesforceSaturday : Salesforce BIG Objects Explained#SalesforceSaturday : Salesforce BIG Objects Explained
#SalesforceSaturday : Salesforce BIG Objects Explained
 
Powerpivot web wordpress present
Powerpivot web wordpress presentPowerpivot web wordpress present
Powerpivot web wordpress present
 
Android list view tutorial by Javatechig
Android list view tutorial by JavatechigAndroid list view tutorial by Javatechig
Android list view tutorial by Javatechig
 
How to grow GraphQL and remove SQLAlchemy and REST API from a high-load Pytho...
How to grow GraphQL and remove SQLAlchemy and REST API from a high-load Pytho...How to grow GraphQL and remove SQLAlchemy and REST API from a high-load Pytho...
How to grow GraphQL and remove SQLAlchemy and REST API from a high-load Pytho...
 
ListView and Custom ListView on Android Development [Thai]
ListView and Custom ListView on Android Development [Thai]ListView and Custom ListView on Android Development [Thai]
ListView and Custom ListView on Android Development [Thai]
 
Lecture Slides for List Views [Android ]
Lecture Slides for List Views [Android ]Lecture Slides for List Views [Android ]
Lecture Slides for List Views [Android ]
 
SFDC Data Models For Pros - Simplifying The Complexities
SFDC Data Models For Pros - Simplifying The ComplexitiesSFDC Data Models For Pros - Simplifying The Complexities
SFDC Data Models For Pros - Simplifying The Complexities
 
form view
form viewform view
form view
 

Semelhante a Salesforce meetup | Lightning Web Component

Use Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDEUse Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDE
Benjamin Cabé
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
Fabio Franzini
 
CiklumJavaSat_15112011:Alex Kruk VMForce
CiklumJavaSat_15112011:Alex Kruk VMForceCiklumJavaSat_15112011:Alex Kruk VMForce
CiklumJavaSat_15112011:Alex Kruk VMForce
Ciklum Ukraine
 
Developing your first application using FI-WARE
Developing your first application using FI-WAREDeveloping your first application using FI-WARE
Developing your first application using FI-WARE
Fermin Galan
 
Spring first in Magnolia CMS - Spring I/O 2015
Spring first in Magnolia CMS - Spring I/O 2015Spring first in Magnolia CMS - Spring I/O 2015
Spring first in Magnolia CMS - Spring I/O 2015
Tobias Mattsson
 
Developing your first application using FIWARE
Developing your first application using FIWAREDeveloping your first application using FIWARE
Developing your first application using FIWARE
FIWARE
 

Semelhante a Salesforce meetup | Lightning Web Component (20)

Developer Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for BeginnersDeveloper Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for Beginners
 
Terraform & Oracle Cloud Infrastructure
Terraform & Oracle Cloud InfrastructureTerraform & Oracle Cloud Infrastructure
Terraform & Oracle Cloud Infrastructure
 
Rits Brown Bag - Salesforce Lightning
Rits Brown Bag - Salesforce LightningRits Brown Bag - Salesforce Lightning
Rits Brown Bag - Salesforce Lightning
 
Google app engine by example
Google app engine by exampleGoogle app engine by example
Google app engine by example
 
Use Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDEUse Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDE
 
Modular Test-driven SPAs with Spring and AngularJS
Modular Test-driven SPAs with Spring and AngularJSModular Test-driven SPAs with Spring and AngularJS
Modular Test-driven SPAs with Spring and AngularJS
 
Vaadin 7 CN
Vaadin 7 CNVaadin 7 CN
Vaadin 7 CN
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
Lessons from a year of building apps with React Native
Lessons from a year of building apps with React NativeLessons from a year of building apps with React Native
Lessons from a year of building apps with React Native
 
CiklumJavaSat_15112011:Alex Kruk VMForce
CiklumJavaSat_15112011:Alex Kruk VMForceCiklumJavaSat_15112011:Alex Kruk VMForce
CiklumJavaSat_15112011:Alex Kruk VMForce
 
Developing your first application using FI-WARE
Developing your first application using FI-WAREDeveloping your first application using FI-WARE
Developing your first application using FI-WARE
 
JahiaOne - Jahia7: Query and Search API under the Hood
JahiaOne - Jahia7: Query and Search API under the HoodJahiaOne - Jahia7: Query and Search API under the Hood
JahiaOne - Jahia7: Query and Search API under the Hood
 
Headless Drupal en pratique
Headless Drupal en pratiqueHeadless Drupal en pratique
Headless Drupal en pratique
 
Hands-On Lab: Improve large network visibility and operational efficiency wit...
Hands-On Lab: Improve large network visibility and operational efficiency wit...Hands-On Lab: Improve large network visibility and operational efficiency wit...
Hands-On Lab: Improve large network visibility and operational efficiency wit...
 
Spring first in Magnolia CMS - Spring I/O 2015
Spring first in Magnolia CMS - Spring I/O 2015Spring first in Magnolia CMS - Spring I/O 2015
Spring first in Magnolia CMS - Spring I/O 2015
 
Developing your first application using FIWARE
Developing your first application using FIWAREDeveloping your first application using FIWARE
Developing your first application using FIWARE
 
Stencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrivedStencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrived
 
Serverless Angular, Material, Firebase and Google Cloud applications
Serverless Angular, Material, Firebase and Google Cloud applicationsServerless Angular, Material, Firebase and Google Cloud applications
Serverless Angular, Material, Firebase and Google Cloud applications
 
Quick Fetch API Introduction
Quick Fetch API IntroductionQuick Fetch API Introduction
Quick Fetch API Introduction
 
SeedStack feature tour
SeedStack feature tourSeedStack feature tour
SeedStack feature tour
 

Mais de Accenture Hungary

Java projekt bemutató - Accenture Technology Meetup
Java projekt bemutató - Accenture Technology MeetupJava projekt bemutató - Accenture Technology Meetup
Java projekt bemutató - Accenture Technology Meetup
Accenture Hungary
 

Mais de Accenture Hungary (13)

Virtual validation tool
Virtual validation toolVirtual validation tool
Virtual validation tool
 
Industry X.0 | Smart Factory | Session no.3
Industry X.0 | Smart Factory | Session no.3Industry X.0 | Smart Factory | Session no.3
Industry X.0 | Smart Factory | Session no.3
 
Accenture Salesforce Developer Meetup vol 1 2019
Accenture Salesforce Developer Meetup vol 1 2019Accenture Salesforce Developer Meetup vol 1 2019
Accenture Salesforce Developer Meetup vol 1 2019
 
PLC Student Meetup
PLC Student MeetupPLC Student Meetup
PLC Student Meetup
 
Industry X.0 | Smart Factory | Session no.2
Industry X.0 | Smart Factory | Session no.2Industry X.0 | Smart Factory | Session no.2
Industry X.0 | Smart Factory | Session no.2
 
SAP S4/HANA meetup overview
SAP S4/HANA meetup overview SAP S4/HANA meetup overview
SAP S4/HANA meetup overview
 
Industry X.0 | Smart Factory | Session no.1
Industry X.0 | Smart Factory | Session no.1Industry X.0 | Smart Factory | Session no.1
Industry X.0 | Smart Factory | Session no.1
 
Accenture Java meetup
Accenture Java meetupAccenture Java meetup
Accenture Java meetup
 
Introduction to NEW SAP - Accenture Technology Meetup
Introduction to NEW SAP - Accenture Technology MeetupIntroduction to NEW SAP - Accenture Technology Meetup
Introduction to NEW SAP - Accenture Technology Meetup
 
SCADA a gyakorlatban - Accenture Industry X.0 Meetup
SCADA a gyakorlatban - Accenture Industry X.0 MeetupSCADA a gyakorlatban - Accenture Industry X.0 Meetup
SCADA a gyakorlatban - Accenture Industry X.0 Meetup
 
Java projekt bemutató - Accenture Technology Meetup
Java projekt bemutató - Accenture Technology MeetupJava projekt bemutató - Accenture Technology Meetup
Java projekt bemutató - Accenture Technology Meetup
 
Java springboot microservice - Accenture Technology Meetup
Java springboot microservice - Accenture Technology MeetupJava springboot microservice - Accenture Technology Meetup
Java springboot microservice - Accenture Technology Meetup
 
Digital Thread & Digital Twin
Digital Thread & Digital TwinDigital Thread & Digital Twin
Digital Thread & Digital Twin
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 

Salesforce meetup | Lightning Web Component

  • 1. ACCENTURE TECHNOLOGY MEETUP A GENERIC RELATED LIST IN LIGHTNING WEB COMPONENT Laura Fulmer Salesforce Developer
  • 2. ABOUT THE PRESENTER Laura Fulmer laura.fulmer@accenture.com Salesforce Developer Certifications: – Platform App Builder – Platform Developer I – Einstein Analytics and Discovery Consultant
  • 3. AGENDA Copyright © 2020 Accenture. All rights reserved. 3 About the LWC • What are these components? • Aura vs. LWC • Parts of the package • Advantages and considerations Demo • Wrapper Class • Dynamic query • Flatten the object structure • Grouping and Concatenating
  • 4. WHAT ARE LIGHTNING WEB COMPONENTS? Copyright © 2020 Accenture. All rights reserved. 4 • A new programming model for building Lightning components that leverages the web standards breakthroughs of 2014-2019 • LWC is an implementation of the W3C’s Web Components standards • Provides a layer of specialized Salesforce services on top of the core stack • Can coexist and interoperate with the Aura model • Unparalleled performance
  • 5. AURA VS. LWC Copyright © 2020 Accenture. All rights reserved. 5 • Aura and LWC components can coexist and interoperate in the same org and on same page • They can share the same – Underlying services – Base Lightning components – High leves services • Aura can include LWC but LWC cannot include Aura Lightning Components Security Lightning Data Service Base Lightning Components Custom component model Custom components Rendering optimization Custom modules Custom events Web components Templates Custom elements Shadow DOM Modules Standard events Events Standard elements Rendering ECMAScript 5 ECMAScript 7 Aura Programming Model Lightning Web Components Programming Model
  • 6. AURA VS. LWC FILE MAPPING IN THE COMPONENT BUNDLE Copyright © 2020 Accenture. All rights reserved. 6
  • 7. Copyright © 2020 Accenture. All rights reserved. 7 CONFIGURATION FILE <?xml version="1.0" encoding="UTF-8"?> <LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata"> <apiVersion>48.0</apiVersion> <isExposed>true</isExposed> <targets> <target>lightning__RecordPage</target> <objects> <object>Account</object> </objects> <target>lightning__HomePage</target> </targets> <targetConfigs> <targetConfig targets="lightning__RecordPage, lightning__HomePage"> <property name="subject" type="String" default="" label="Name of the person you want to greet"/> <property name="greeting" type="String" default="" label="Greeting" /> </targetConfig> </targetConfigs> </LightningComponentBundle> <design:component label="Hello World"> <design:attribute name="subject" label="Subject" description="Name of the person you want to greet" /> <design:attribute name="greeting" label="Greeting" /> </design:component> LWC Aura
  • 8. Copyright © 2020 Accenture. All rights reserved. 8 JAVASCRIPT ({ count : function(component, event, helper){ let greeting = component.get("v.greeting"); alert(greeting.length + " letters"); } }) import { LightningElement, track } from 'lwc'; export default class HelloLwc extends LightningElement { @track greeting = 'World'; handleChange(event){ this.greetig = event.target.value; } count(){ alert(this.greeting.length + " letters"); } } LWC Aura
  • 9. Copyright © 2020 Accenture. All rights reserved. 9 HTML <template> <lightning-card title="Hello_LWC"> <lightning-button label="count" onclick={count}> </lightning-button> <div class="slds-m-around_medium"> <p>Hello, {greeting}!</p> <lightning-input label="Name" value={greeting} onchange={handlechange}> </lightning-input> </div> </lightning-card> </template> <aura:component implements="flexipage:availableForAllPageTypes" access="global"> <aura:attribute name="greeting" type="String"> <lightning:card title="Hello_Aura"> <aura:set attribute="actions"> <lightning:button label="count" onclick="{!c.count}"/> </aura:set> <div class="slds-m-around_medium"> <p>Hello, {!v.greeting}!</p> <lightning:input label="Name" value="{!v.greeting}"/> </div> </lightning:card> </aura:component> LWC Aura
  • 10. Copyright © 2020 Accenture. All rights reserved. 10 CSS • No need for .THIS • Standard CSS syntax • To override lightning design use loadStyle and static resource • CSS styles defined in a parent component don’t reach into a child. .boxLarge { width: 200px; height: 200px; border: 1px solid red; background-color: #344A5F; } .boxSmall { width: 100px; height: 100px; margin: auto; background-color: #F0F1F2; }
  • 11. Copyright © 2020 Accenture. All rights reserved. 11 LIFECYCLE HOOKS constructor() called parent connectedCallback() called on parent render() called parent renderedCallback() called on parent constructor() called on child connectedCallback() called on child render() called on child renderedCallback() called on child Properties assigned Parent Component Child Component 1 2 3 8 7 6 5 4 Properties assigned Parent created
  • 12. 12Copyright © 2020 Accenture. All rights reserved. ADVANTAGES OF THE LWC BETTER PERFORMANCE Faster loading sites MORE STANDARD Built-in browser security features, more out-of- the-box solutions and less customization BETTER BROWSER COMPATIBILITY More consistency SERVICE COMPONENT More reusable and efficient components without UI elements EASY TO LEARN Based on native web standards, no added abstraction layer
  • 13. 13Copyright © 2020 Accenture. All rights reserved. CONSIDERATIONS OF THE USAGE OF LWC UNSUPPORTED EXPERIENCES AND TOOLS APIs, Actions and Chatter extension MOBILE SDK DOESN’T SUPPORT IT Wrapping it in Aura is also unsupported CANNOT CONTAIN AURA This needs to be considered upon planning
  • 14. DEMO
  • 15. OBJECT STRUCTURE Copyright © 2020 Accenture. All rights reserved. 15 ContactLead Reservation__c Market__c Space__c
  • 16. The dynamic query is built on the information from the Admin user SELECT [Field Set name] FROM [Child object API name] WHERE [Parent field API name on child object] = recordId AND [Additional filter in SOQL format] SORT BY [API name of the field that is the base of sorting] [Sort Direction] DYNAMIC QUERY Copyright © 2020 Accenture. All rights reserved. 16
  • 17. Copyright © 2020 Accenture. All rights reserved. 17 public class lightningTableColumnWrapper { @AuraEnabled public string label {get;set;} @AuraEnabled public String fieldName {get;set;} @AuraEnabled public string type {get;set;} @AuraEnabled public boolean sortable {get;set;} } WRAPPER CLASS public class lightningTableWrapper{ @AuraEnabled public List<sObject> tableRecord {get;set;} @AuraEnabled public List<lightningTableColumnWrapper> tableColumn {get;set;} @AuraEnabled public Map<String,String> referenceValMap{get;set;} }
  • 18. Copyright © 2020 Accenture. All rights reserved. 18 FLATTEN THE OBJECT STRUCTURE FOR THE DATATABLE I
  • 19. Copyright © 2020 Accenture. All rights reserved. 19 changeIdToName(output) { for (let i = 0; i < this.totalCount; i++) { let currentObject = {}; Object.assign(currentObject, this.resp.tableRecord[i]); currentObject.Id = '/' + currentObject.Id; for (let j = 0; j < Object.keys(currentObject).length; j++) { let currentField = Object.keys(currentObject)[j]; if (typeof currentObject[currentField] === 'object') { const newVal = currentObject[currentField].Id ? ('/' + currentObject[currentField].Id) : null; this.flattenStructure(currentObject, currentField + '_', currentObject[currentField]); currentObject[currentField] = newVal; } } output.push(currentObject); } } FLATTEN THE OBJECT STRUCTURE FOR THE DATATABLE II flattenStructure(topObject, prefix, toBeFlattened) { // eslint-disable-next-line guard-for-in for (const prop in toBeFlattened) { const curVal = toBeFlattened[prop]; if (typeof curVal === 'object') { this.flattenStructure(topObject, prefix + prop + '_', curVal); } else { topObject[prefix + prop] = curVal; } } }
  • 20. Copyright © 2020 Accenture. All rights reserved. 20 groupFields(output) { let groups = {}; let groupField = this.groupBy; groups = output.reduce(function (initialValue, currentValue) { initialValue[currentValue[groupField]] = initialValue[currentValue[groupField]] || []; let currentRecord = {}; Object.assign(currentRecord, currentValue); initialValue[currentValue[groupField]].push(currentRecord); return initialValue; }, Object.create(null)); return groups; } GROUPING FIELDS
  • 21. Copyright © 2020 Accenture. All rights reserved. 21 concatenateFields(groups, cols) { let concatArray = []; for (let i = 0; i < Object.keys(groups).length; i++) { this.totalCount = Object.keys(groups).length; let currentGroupName = Object.keys(groups)[i]; let currentGroup = groups[currentGroupName]; //Looping over the columns of the current group for (let j = 0; j < cols.length; j++) { let currentField = cols[j].fieldName; //Looping over the records of the current group for (let l = 0; l < currentGroup.length; l++) { //If the value in the first line is undefined, make it equal with the current value if (currentGroup[0][currentField] === undefined) { currentGroup[0][currentField] = currentGroup[l][currentField]; } CONCATENATE VALUES //If the current value is NOT undefined or the first value does not contain it, concatenate it to the first one if (currentGroup[l][currentField] !== undefined && !currentGroup[0][currentField] .includes(currentGroup[l][currentField])) { currentGroup[0][currentField] += ', ' + currentGroup[l][currentField]; } } } concatArray.push(currentGroup[0]); } return concatArray; }
  • 22. Q&A
  • 24. USEFUL LINKS Copyright © 2020 Accenture. All rights reserved. 24 Component Reference: developer.salesforce.com/docs/component-library/overview/components LWC sample apps: trailhead.salesforce.com/sample-gallery Salesforce Lightning Design System: lightningdesignsystem.com Supported Salesforce experiences and tools in LWC: developer.salesforce.com/docs/component- library/documentation/en/lwc/lwc.get_started_supported_experiences Open source base components: github.com/salesforce/base-components-recipes