Is it possible to get field info (esp. picklist values) in an LWC controller for dynamically specified fields?
The getPicklistValue docs demonstrates fetching data for an explicit field, but is there a way to decide the field at runtime?
E.g.
// NOT-REAL-CODE
import { LightningElement, api, wire } from 'lwc';
import { getPicklistValues } from 'lightning/uiObjectInfoApi';
import DYNAMIC_FIELD from '@salesforce/schema/Account.{userSpecifiedFieldName}';
export default class Example extends LightningElement {
@api userSpecifiedFieldName;
@wire(getPicklistValues, { recordTypeId: '012000000000000AAA', fieldApiName: DYNAMIC_FIELD})
propertyOrFunction;
}
I know it's possible to do this using the Schema object in an APEX class, but since it requires going to the server this is expensive for my use-case.
If it's useful to anyone else, here's the docs on calling APEX from LWC and a useful article on using Schema to get picklist values.