Using Picklists¶
Available Liferay DXP/Portal 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.
Note
Once 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¶
Once a list is created, you can select it when creating Object fields. Select the Picklist field type and choose the desired 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.
Important
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 them, you can perform CRUD operations for both Picklist Definitions (ListTypeDefinition
) and Picklist Entries (ListTypeEntry
).
Picklist Fields in Object API Calls¶
For 7.4+ U1+/GA5+
When making POST, PATCH, and PUT API calls for Objects that include a Picklist field, you must use the following format.
{
"picklistExample": {
"key": "secondOption",
"name": "Second Option"
}
}