Skip to content

Using the UI API with LWC

User Interface API gives you payloads of Salesforce data and metadata that are structured for building UI. Salesforce uses User Interface API to build Lightning Experience. UI API makes it simple to build a custom user interface according to the rules and permissions inside a Salesforce org because the UI responds to metadata changes at runtime.

Benefits of using UI API :

  • Formatted and Localized Display Values
  • Layout Types and Form Factors
  • Field-level Security and Sharing Rules
  • Support declarative changes with no code update

Now, lets talk about using the UI API in LWC. We can use UI API in two ways in LWC:

  1. Using base components – Its a simple approach which outputs a UI without the need of JS or Apex.
  2. Using the UI API wire adapters and functions – A flexible approach which outputs no UI and require some JS but no apex.

Using base components

Render record forms with any of these three base components

  • lightning-record-form
  • lightning-record-view-form
  • lightning-record-edit-form

Using the UI API wire adapters and functions

Query the UI API with wire adapters and functions exposed in the following modules to work with Salesforce data and metadata :

  1. lightning/ui-list-api (Beta) – Get the records and metadata for a list view.
  2. lightning/ui-object-info-api – This module is used to get object metadata, and get picklist values.
  3. lightning/ui-record-api – This module includes wire adapters to record data and get default values to create records.
  4. lightning/ui-apps-api (Beta) – Get data and metadata for apps displayed in the Salesforce UI.

Note – Not all standard objects are supported by standard ui-api modules. Please find the supported standard objects here.

Hope you liked it. Please find below references for more details:

Published inCoding Mania

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *