Using Picklists
Available Liferay 7.4+
Picklists is an application for creating standard lists of values that are understood across the Liferay Portal. The process of creating a Picklist includes creating the initial list and adding items to it. Once these values are defined, they can be used in supported applications.
Creating a Picklist
Follow these steps to create a Picklist:
Open the Global Menu (
), go to the Control Panel tab, and click Picklists.
Click the Add button (
).
Enter a Name for the Picklist, and click Save. This value identifies the list in the Liferay UI and can be localized after creation.
Click the new Picklist to edit it.
Under Items, click the Add button (
).
In the modal window, enter a Name and Key for the item.
Name: Determines the item’s display name and can be localized after creation.
Key: Determines the standard value understood by applications in the back-end and uses camel case.
noteOnce created, an Item’s key cannot be changed, but you can edit its name or delete it at any time.
Click Save. This immediately updates the Picklist with the new item.
Repeat the above steps to add additional items to the list.
Adding Picklist Fields to Objects
For 7.4 U56+/GA56+
After creating a list, you can select it when creating Object fields. Select the Picklist or Multiselect Picklist field type and choose the list. See Adding Fields to Objects for more information.
When users access this field in an Object’s layout, it appears as a drop-down menu that lists the Picklist’s items.
A list cannot be deleted if it is used by an Object field, though list items can be edited and removed at any time.
Updating or deleting a Picklist item automatically updates all Object entries using the item value.
Picklist APIs
Liferay provides headless APIs for creating and managing Picklists. You can view available Picklist APIs in Liferay’s API Explorer at localhost:8080/o/api
under headless-admin-list-type
.
With Picklist APIs, you can perform CRUD operations for both Picklist Definitions (ListTypeDefinition
) and Picklist Entries (ListTypeEntry
). See Picklist API Basics for more information.
Picklist Fields in Object API Calls
For 7.4 U56+/GA56+
When making POST, PATCH, and PUT API calls for Objects that include a Picklist field, you must use the following request payload formats for Picklists and Multiselect Picklists, respectively.
Picklist Field Type
{
"picklistExample": {
"key": "firstOption",
"name": "First Option"
}
}
Multiselect Picklist Field Type
{
"picklistExample": [
{
"key": "firstOption",
"name": "First Option"
},
{
"key": "secondOption",
"name": "Second Option"
}
]
}