6

The docs here indicate, that the onload-action return the following:

Parameter : recordUi
Type : Object
Description : The object metadata. For more information, see the User Interface API Developer Guide.

Actually I just can't figure how to implement it to retrieve and use this recordUi parameter. I'm looking on this doc to use actions, but I can't connect the dots on how to grab the parameter.

Any idea?

Need no fully working code. Just fragments, hints or a link would be good enough - the rest I can figure on my own.

Update

@sfdcfox solution works, but the parameter unfortunately only console.logs as "Proxy {}" - whatever it means. The parameter is existent, because for non-existent params you'll get "undefined".

But it seems unusable or intentionally inaccessibly or it's just a mere bug...

Why I want this?

Not long ago I've asked this question Is User Interface API accessible via JS from a Helper of a Lightning Component? and I think here we could get maybe access to some parts of the UI-API indirectly by hijacking an invisible lightning:recordEditForm and leech out the recordUi and use it for my own purposes...

My earlier question is still unanswered - so my guess is, that it's not super-easy to use the UI-API in Lightning Compos. Having an workaround without dealing with all kinds of callout-challanges could by helpful.

Result

Yes we can! Thanks to the answer of @sfdcfox we can get something (in fact a lot). I will just need to review it in depth and try to get rid of the warnings.

The console dump looks like this, and this is only the tip of the iceberg: enter image description here

  • This seems to be unstable in managed packages. RecordUi is not always loaded correctly, some fields can be missing. There seems to be some dependency in what fields are loaded. I have not fully figured out what exactly. Could be Field level security, but could also be the page layout – Karsten Nov 28 '18 at 7:58
8

It's an event handler, so you just use it like an attribute that accepts a controller method:

<lightning:recordEditForm onload="{!c.recordLoaded}" ...

function recordLoaded(component, event, helper) {
  var recordUi = event.getParam("recordUi");
  ...
|improve this answer|||||
  • cool, that works... but unfortunately the thing console.logs only as "Proxy {}" - whatever it means. The parameter is existent, but unusable as it seems or intentionally inaccessibly or it's a bug. Seems that it's unusable, but you answer is perfectly right! – Uwe Heim May 4 '18 at 11:32
  • @UweHeim It is usable. Proxy just means that it's Locker Service locked down. To see the keys on it, try Object.keys(recordUi). – sfdcfox May 4 '18 at 11:39
  • cool, thx. Is there a simple way to recursively dump the entire object with all it's sublevels on the console so that I can have a quick glance on everything returned? Or is it necessary to crawl through that nested thing "manually"? Because of it's functions instead of plain properties, the browser-console can't do a great job in dumping it out. – Uwe Heim May 4 '18 at 11:45
  • @UweHeim JSON.stringify can convert the object to a plain JSON string. You'll probably want to read the docs and/or copy the JSON to a JSON formatter so you can read it easier. – sfdcfox May 4 '18 at 11:50
  • onsole.log( JSON.stringify( evt.getParam("recordUi") ) ) brings A HUGE bloat of warnings, but finally there are values!!! and lots of them! I will need to inspect that deeper, but generally it seems feasible to leech some UI-API stuff in Lightning Components without having to call the API ;-) – Uwe Heim May 4 '18 at 11:55

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.