[SalesForce] How to populate picklist values in Lightning Componets according to the metadata definition

In Visualforce, we didn't thought much about picklist-values (=options) on simple CRUD UIs – they where simply there using an <apex:inputField ... />

Now in Lightning I found this documentation showing different verbose ways to populate the options either by Markup or JavaScript, but both none driven by metadata – https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ui_select.htm

I like neither of those approaches. Is there any method to get this done better?

The goal is, to populate the values as defined in the setup

  • Record-Type aware
  • Translation aware
  • Dependency aware

A similar (but more specific) question has been asked here Picklist Values in Dynamic Lightning Components

I think in addition to record-type specific values, there are many reasons to make this dynamic, e. g. translations. It is not simple to populate a picklist with exactly the same values as user will see in the standard-UI. Assuming an complex org is already well-configured, it might be a huge piece of work to populate the picklists (reading the schema, evaluating the record-types, translations, etc). This should be done – as in Visualforce – by the platform, but how does it work?

To hardcode picklist-values is the worst option, because you will end up in maintaining them redundatly multiple times, loose configurability by admins and significantly higher implementation efforts.

Best Answer

There is something...

I found this post Lightning - How to use force:inputField? and I'm validating this markup

<force:inputField value="{!v.YourAttributeNameForTheSObject.YourFieldname}" />

It's in the documentation

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_compref_force_inputField.htm

The description is very puristic (no further explanation, no example) and this is currently the only match in the documentation I found. It leaves many questions open.

And it works partly. As @Andrew discoverd, picklists come up disabled. Using jQuery to wipe the disabled="" makes them editable and I was surprisingly be able to change a picklist-value and get it saved.

So what does this tell us?

  • Is this officially available or not?
  • What is it capable of and what not?
  • Should we use it or not?
  • Will there be an improvement of documentation and functionality soon?

Please let us know, so that we can plan ahead. This is nothing small. This is very very big - at least in my opinion, since to use ui:inputXXXX is very poor compared to force:inputField