getPicklistValues

Use this wire adapter to get the picklist values for a specified field.

getPicklistValues uses this User Interface API resource.

  • recordTypeId—(Required) The ID of the record type. Use the Object Info defaultRecordTypeId property, which is returned from getObjectInfo. If there isn’t a default record type, this value is the master record type, which is 012000000000000AAA.
  • fieldApiName—(Required) The API name of the picklist field on a supported object.

Read the data that's returned by the wire adapter using a property or function.

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.

Using objectApiName with this wire adapter isn't supported since this information is also already included with fieldApiName.

Picklist values are scoped to a record type. For dependent picklists, getPicklistValues returns data for controlling fields and how they map to the picklist. For more information, see Build UI for Picklists.

To retrieve all picklists of a record type, use getPicklistValuesByRecordType instead.

Both the recordTypeId and fieldApiName parameters are required. To provide the recordTypeId value, use the getObjectInfo wire adapter and set the defaultRecordTypeId property on a reactive variable. Then, pass the reactive variable to the getPicklistValues wire adapter.

This example returns the picklist values-Hot, Warm, and Cold-from the Rating field on Account.

data.values returns a list of picklist labels and values. See Picklist Value.

To display the picklist values on your component, iterate over the list using the for:each directive.

The wireGetPicklistValues component in the lwc-recipes GitHub repo gets the picklist values for an Account field.

See Also