7

Can we use the UI API in Lightning Components directly from within a Helper JS?

https://developer.salesforce.com/docs/atlas.en-us.uiapi.meta/uiapi/ui_api_get_started.htm

I've just read the docs and found no example for a Lightning use case. Maybe I've only missed it.

Can anyone point me to an existing example? Or provide a short answer if not feasible or not officially supported.

I haven't tried it so far, but it's GET-based design lets me suspect challenges with LockerService, XSS, CORS, CSP and whatever else is around there to protect us against bad guys and also against ourselves. Might Oauth be tricky? Can I use the Session ID instead Oauth?

For me it looks like it's not designed to be used from within lightning components JS. But it would help me a lot to have Information dynamically in the JS-layer like picklist values, layouts, etc. to create very dynamic LCs.

As a workaround I can imagine that it's accessible via APEX. But I don't like that way and also I suspected the user to need high privileges. For a read-access I would like very low privileged users to get information about their available picklist values, etc. realtime, on the fly, freshly requested on any impression of my LC. Maybe the API-access would also have a tick against Limits on every use?

Or is there a better alternative to get all that good stuff in LC's JS?

2

Yes it us possible using LWC components Further using LWC components inside aura components you can get data in aura component

Basic flow would be

  1. Creating lwc components that retrieves desired data using recordUi api
  2. exposing required variable using @api decorated so that they can be passed from an aura components
  3. pass received data using the custom event
  4. handle custom event in aura component

Check this git link that has an example

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.