Successfully reported this slideshow.

LWC Datatable LDV, Christian Knapp & Christian Menzinger

0

Share

1 of 62
1 of 62

LWC Datatable LDV, Christian Knapp & Christian Menzinger

0

Share

Download to read offline

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.

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.

More Related Content

More from CzechDreamin

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all

LWC Datatable LDV, Christian Knapp & Christian Menzinger

  1. 1. Having serious fun with LWC Datatable and Large Data Volume by Christian Szandor Knapp & Christian Menzinger
  2. 2. #CD22 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
  3. 3. #CD22 - 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 Fairytale Today
  4. 4. #CD22 Chapter ~ I ~
  5. 5. #CD22 In a Land far, far away
  6. 6. #CD22 … there was a charming product owner princess Once upon a time, in a land far, far away …
  7. 7. #CD22 … and two innocent developers. (Full Hair) (Beard) (Hat)
  8. 8. #CD22 They were working happily together
  9. 9. #CD22 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 …
  10. 10. #CD22 A meeting, two days before … His dog, Franz K., Architect Herr Governor Limit Karl, 4th Gen CEO Inherited an Empire (Pricebook)
  11. 11. #CD22 “This is our idea”, princess said
  12. 12. #CD22 “Find products by tabular search”, princess said
  13. 13. #CD22 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.
  14. 14. #CD22 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)
  15. 15. #CD22 “Here are a few pointers for you”, princess said
  16. 16. #CD22 Questions? Any elephants in the room? For example: - Are we rebuilding Standard Product Search on Opportunity? - Is this a good idea?
  17. 17. #CD22 Chapter ~ II ~
  18. 18. #CD22 Trails for Rangers, Crossroads for Heroes
  19. 19. #CD22 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)
  20. 20. #CD22 Forward Looking Statement
  21. 21. #CD22 Official cause of death Governor Limit RI P You died Invalid Type Coercion Platform Restrictions Fuzzy (Ideas about) Requirements Racing Conditions / Flags Performance Issues currently in Beta or Deprecated
  22. 22. #CD22
  23. 23. #CD22 Chapter ~ III ~
  24. 24. #CD22 The mole’s tale Summer is coming
  25. 25. #CD22 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*
  26. 26. #CD22 He’s a curious and crafty krtek I’m off building a tiny Proof of Concept I’m back in an hour
  27. 27. #CD22 He’s a curious and crafty krtek I will - Set up a Scratch Org with sample 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
  28. 28. #CD22 Official cause of death RI P You died Platform Restrictions Racing Conditions / lags currently in Beta or Deprecated
  29. 29. #CD22 Official cause of death RI P You died again Platform Restrictions Racing Conditions / lags currently in Beta or Deprecated Needs a higher API version than supported by LWC Local Development
  30. 30. #CD22 First Demo
  31. 31. #CD22 Forward looking statement RI P You died Performance Issues
  32. 32. #CD22 A Scratch Org comes with <30 Products Use Open Source tools for data Snowfakery Config / CumulusCI:
  33. 33. #CD22 Death by Platform Restriction / Limits? Use Open Source Tools for Data Snowfakery Config / CumulusCI:
  34. 34. #CD22 SUMMER IS COMING
  35. 35. #CD22 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()
  36. 36. #CD22 Although we called it “Tabular Product Search” It is not Products we are looking for but PricebookEntries Official cause of death RI P You died Fuzzy (Ideas about) Requirements
  37. 37. #CD22 Official cause of death RI P You died again Platform Restrictions PricebookEntries Do Not Support ListViews
  38. 38. #CD22 Official cause of death RI P You almost died a 3rd time Racing Conditions / Flags Wire Adapters are supported only in @wired decorated properties/function No Promise.all() available
  39. 39. #CD22 Official cause of death Governor Limit RI P You died a 3rd time Performance Issues currently in Beta or Deprecated
  40. 40. #CD22 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?
  41. 41. #CD22
  42. 42. #CD22 Sorting should work exactly like in Salesforce We sort things all of the time in reports or list views Of course …
  43. 43. #CD22 “This should be simple”, princess said
  44. 44. #CD22 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
  45. 45. #CD22 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
  46. 46. #CD22 Chapter ~ IV ~
  47. 47. #CD22 The dwarf’s tale We dig dig dig dig dig dig dig
  48. 48. #CD22 The actual Fairytale (Query based on String Inputs) (Large Data Volume) (Strongly Typed)
  49. 49. #CD22 Official cause of death Invalid Type Coercion Fuzzy (Ideas about) Requirements RI P You died Platform Restrictions
  50. 50. #CD22 Should you know the dwarf…
  51. 51. #CD22 Where Clauses and not yet dynamic SOQL
  52. 52. #CD22 Official cause of death RI P You died Platform Restrictions RI P You died
  53. 53. #CD22 Finally…
  54. 54. #CD22 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
  55. 55. #CD22 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
  56. 56. #CD22 ~ OPEN END ~
  57. 57. #CD22 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
  58. 58. #CD22 ~ RESOURCES / LINKS~
  59. 59. #CD22 “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
  60. 60. #CD22 ~ Q & A ~
  61. 61. #CD22 appero GmbH is hiring a new Head of Development Thank you for 5+ amazing years Wanna wear my hat?
  62. 62. Thank you! #CD22

Editor's Notes

  • “What did we miss in the meantime?” “ A meeting, two days before between Franz and Karl …. “
  • Why not Pricebook Entry List View? Because not available / supported . admins cannot configure listviews on PBE
  • Answer: Partly, yes. Opp Product Search works only in one place, though. We build a level more generic - the same search can be used for opp products as well as order products for example. Assets could work similarly.
  • See, if our heroes had only known what expected them.

    But they didn’t. Ignorance is a bliss sometimes.
  • Hop into documentation
  • Scratch Org timeouts didn’t help, either…
  • Krtek made his demo much simpler;
  • Now, how can that happen in the very first PoC?
  • NO death by governor limit?
  • NO death by governor limit? Nope; not even data limits :)
  • It is still Spring, virtual rendering is only available in Sandboxes / Preview Orgs

    Even if we could why would we want to load 5000+ records?

    Given we have a 1.5 M Products (and pricebook entries), we could hit the 50.000 query row limit


  • Why / where should we sort / how?
  • String.prototype.localeCompare() - JavaScript | MDN (mozilla.org)
  • Why / where should we sort / how?
  • SOQL / SOSL ?
  • Over 20 DisplayTypes
    DisplayType Enum | Apex Reference Guide | Salesforce Developers

  • This is a best case scenario


    Is this secure?
  • Long text not searchable
  • Explain switch statement
  • The most records that could ever be returned for the query to be considered selective is 1M but the total data set size would need to be > 5.6M records

    Steve Baines
  • The most records that could ever be returned for the query to be considered selective is 1M but the total data set size would need to be > 5.6M records

    Steve Baines
  • I have a question: why was there never any mention of large data volume again?
  • I have a question: why was there never any mention of large data volume again?
  • ×