LWC Datatable LDV, Christian Knapp & Christian Menzinger
CzechDreamin
170 views
62 slides
Jun 14, 2022
Slide 1 of 62
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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...
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 fixed set of column labels is straightforward and quickly done.
What about the next level, though? Loading a related list for example? Sortable. Searchable. Displaying the table in the user’s end language, with translated columns and values, too, where supported. Scanning a Large Data Volume like 70.000 records.
This talk will not provide a solution. It will focus on the path to a possible solution: Given all these requirements, where do I start? Where and how do I get test records? And 70k! Should sorting happen in the datatable or should Apex do the lifting? Which APIs do I use? When? How often? Where? Why?
Join us for a bit of code and lots of serious, honest experience sharing.
Size: 12.76 MB
Language: en
Added: Jun 14, 2022
Slides: 62 pages
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?