LWC Datatable LDV, Christian Knapp & Christian Menzinger

CzechDreamin 170 views 62 slides Jun 14, 2022
Slide 1
Slide 1 of 62
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47
Slide 48
48
Slide 49
49
Slide 50
50
Slide 51
51
Slide 52
52
Slide 53
53
Slide 54
54
Slide 55
55
Slide 56
56
Slide 57
57
Slide 58
58
Slide 59
59
Slide 60
60
Slide 61
61
Slide 62
62

About This Presentation

Interactive data-tables are awesome and a challenge – LWC’s lightning-datatable is no exception. It has many, useful features, lots of documentation and can handle various use cases from working with single fields to several records.

Loading Salesforce records with a fixed set of fields and a f...


Slide Content

Having serious fun with LWC Datatable and Large Data Volume by Christian Szandor Knapp & Christian Menzinger

About us Christian Menzinger Salesforce Architect, Copado @chris_menzinger https://www.linkedin.com/in/christianmenzinger Christian Szandor Knapp Head of Development, appero @ch_sz_knapp https://www.linkedin.com/in/szandor

Chapter I - In a Land far, far away Chapter II - Trails for Rangers, Crossroads for Heroes Chapter III - The mole’s tale - Summer is coming Chapter IV - The dwarf’s tale - We dig, dig, dig, dig, dig, dig, dig Running out of time Q&A Your F airytale Today

Chapter ~ I ~

In a Land far, far away

… there was a charming product owner princess Once upon a time, in a land far, far away …

… and two innocent developers. (Full Hair) (Beard) (Hat)

They were working happily together

We have a need, she said. It is going to be beautiful, she said. It will be so much fun to build, she said. We use base components, she said. Until one day …

A meeting, two days before … His dog, Franz K., Architect Herr Governor Limit Karl, 4th Gen CEO Inherited an Empire (Pricebook)

“This is our idea”, princess said

“Find products by tabular search”, princess said

Franz, the Architect (sometimes a little too busy) We always empower Admins. Have them configure a List View on Product2. Use the List View to define the table. By the way, a Pricebook has 1.500.000 products per currency. Could get a lot more very quickly.

We have a long standing SAP business relationship. Picklist Values/Keys on Product2 are internal to SAP Picklist Labels give User Guidance Use localized Picklist Labels Make sure fields like Term (12, 24, 36) can be searched. Karl, the Boss (Trailhead Ranger, Part Time Admin)

“Here are a few pointers for you”, princess said

Questions? Any elephants in the room? For example: Are we rebuilding Standard Product Search on Opportunity? Is this a good idea?

Chapter ~ II ~

Trails for Rangers, Crossroads for Heroes

Front End / LEX (Base Components) Backend (Apex) Front End / LEX (Wire Adapters) Project Setup (e.g. Test Data) Where to next? Agile or Waterfall? Backend (sObjects)

Forward Looking Statement

Official cause of death Governor Limit RIP You died Invalid Type Coercion Platform Restrictions Fuzzy (Ideas about) Requirements Racing Conditions / Flags Performance Issues currently in Beta or Deprecated

Chapter ~ III ~

The mole’s tale Summer is coming

Documentation https://developer.salesforce.com/docs/component-library/bundle/lightning-datatable/documentation Examples and useful Snippets https://github.com/trailheadapps/lwc-recipes https://github.com/trailheadapps/apex-recipes )* in comparison to the start of Aura** )** Aura today and all Salesforce Docs are in a much more accessible state than most other docs Excellent state of LWC documentation*

He’s a curious and crafty krtek I’m off building a tiny Proof of Concept I’m back in an hour

He’s a curious and crafty krtek I will Set up a Scratch Org with s ample data using VS Code Pump it full of products Create LWC Use LWC Local Development for fast prototyping Use Wire Adapter to load list view and records! I used that last year

Official cause of death RIP You died Platform Restrictions Racing Conditions / lags currently in Beta or Deprecated

Official cause of death RIP You died again Platform Restrictions Racing Conditions / lags currently in Beta or Deprecated Needs a higher API version than supported by LWC Local Development

First Demo

Forward looking statement RIP You died Performance Issues

A Scratch Org comes with <30 Products Use Open Source tools for data Snowfakery Config / CumulusCI:

Death by Platform Restriction / Limits? Use Open Source Tools for Data Snowfakery Config / CumulusCI:

SUMMER IS COMING

Here’s what we’ve learned A lot about client side performance Why Summer 22 will make it better Why Selections need special care Why there are no shortcut/s via Listview APIs Decisions No data, no table, no columns, no table To talk to Apex we need to know which fields to query first Use getListInfoByName() Salesforce Fields are also columns Columns need type information E.g. Booleans should render as a checkboxes Use getObjectInfo()

Although we called it “Tabular Product Search” It is not Products we are looking for but PricebookEntries Official cause of death RIP You died Fuzzy (Ideas about) Requirements

Official cause of death RIP You died again Platform Restrictions PricebookEntries Do Not Support ListViews

Official cause of death RIP You almost died a 3rd time Racing Conditions / Flags Wire Adapters a re supported only in @wired decorated properties/function No Promise.all() available

Official cause of death Governor Limit RIP You died a 3rd time Performance Issues currently in Beta or Deprecated

Here’s what we’ve learned Loading fewer records is always better for performance Use infinite loading Use offsets to avoid query limits for LDV Use a record limit / threshold for rendered rows in table Have we talked about sorting yet? String.prototype.localeCompare() Or Apex?

Sorting should work exactly like in Salesforce We sort things all of the time in reports or list views Of course …

“This should be simple ”, princess said

Here’s what we’ve learned Loading fewer records is always better for performance Use infinite loading Use offsets to avoid query limits Use a record limit / threshold for rendered rows in table Apex does the sorting Works good within caching Needs a bit of loading otherwise

Summary I LWC provides Offsets Limits Search Term SortedBy Field and Sort Direction LWC is responsible for Providing Initial Data for Apex Query e.g. Field Names Talking to Apex Debouncing Selection Handling Data Wrangling Data Table does not support Contact.Account.Name

Chapter ~ IV ~

The dwarf’s tale We dig dig dig dig dig dig dig

The actual Fairytale (Query based on String Inputs) (Large Data Volume) (Strongly Typed)

Official cause of death Invalid Type Coercion Fuzzy (Ideas about) Requirements RIP You died Platform Restrictions

Should you know the dwarf…

Where Clauses and not yet dynamic SOQL

Official cause of death RIP You died Platform Restrictions RIP You died

Finally…

Summary II Dig, Dig, Dig, Dig, Dig, Dig, Dig Not all field types can / will be supported for text search (Idea) specialised search fields for e.g. date All supported types need to be converted for queries Product2.Description is a special snowflake (Idea) SOSL for long text fields (Challenge) combine User Experience

Summary II Will we meet Large Data Volume Trouble? No due to tight LIMIT clauses Rules differ for standard and custom indices Standard Index Total # of records is < 1M: Query must return less than 30% of total Total # of records > 1M: Query must return <300K rows Custom Index 10% of total records and < 10k rows

~ OPEN END ~

Architectural Mindset: keep asking questions Challenge “simple-use-case” documentation Commit early, commit cleanly, commit often Handling events as they come out of the box is not always the whole truth Product2, PricebookEntry do not count against record limit Inserting 1.5m records is easy, LDV Selective Query Limits are not. Huge Gains in Summer 22 for Datatable Render Performance Random Collection of Take-Aways

~ RESOURCES / LINKS~

“ LWC Utils” by tsalb Includes a Salesforce-Records-To-Datatable Component https://github.com/tsalb/lwc-utils CumulusCI https://trailhead.salesforce.com/en/content/learn/trails/build-applications-with-cumulusci Apex and LWC Recipes https://github.com/trailheadapps/lwc-recipes https://github.com/trailheadapps/apex-recipes Demo Repository for 1.5M Products/PricebookEntries & a simple datatable https://github.com/Szandor72/cd22 - lightning-datatable Resources / Links - all Open Source

~ Q & A ~

a ppero GmbH is hiring a new Head of Development Thank you for 5+ amazing years Wanna wear my hat?