Introducing getPicklistValues for Lightning Web Component!
Use this wire adapter to easily retrieve the picklist values for a specific field.
Syntax:
import { LightningElement, wire } from "lwc";
import { getPicklistValues } from "lightning/uiObjectInfoApi";
import INDUSTRY_FIELD from "@salesforce/schema/Account.Industry";
export default class Example extends LightningElement {
@wire(getPicklistValues, { recordTypeId: "012000000000000AAA", fieldApiName: INDUSTRY_FIELD })
propertyOrFunction;
}
The getPicklistValues method uses this User Interface API resource to fetch the picklist values.
Parameters:
- recordTypeId (Required)
The ID of the record type. Use the Object Info defaultRecordTypeId property, which is returned from getObjectInfo.
- fieldApiName (Required)
The API name of the picklist field on a supported object.
- propertyOrFunction
A private property or function that receives the stream of data from the wire service.
If a property is decorated with @wire, the results are returned to the property’s data property or error property.
If a function is decorated with @wire, the results are returned in an object with a data property and an error property.
Note:
Using objectApiName with this wire adapter isn't supported since this information is already included with fieldApiName.
Returns:
data - An array of Picklist Values.
error - An error object if there was an issue fetching the picklist values.
Follow Us