Adding and Managing Custom States¶
Available Liferay 7.4 U41+ and GA41+
Some use cases may require assigning multiple states to an object entry at the same time. For example, when building an Order application, you may need to assign and manage order, payment, and delivery statuses for the same entry, each with its own flow and associated business logic. Using Liferay picklists with custom objects, you can achieve this functionality.
With picklists, you can define lists of strings and use them as object fields to define custom states for entries. Once added to an object definition, you can design the flow for each state and use validations and actions to add custom business logic for different states. These custom states can also be used alongside workflow statuses to define more complex review and approval processes.
Adding a State Field to Object Definitions¶
Follow these steps to use a picklist to add custom states for an object’s entries:
Open the Global Menu (), click the Control Panel tab, and go to Picklists.
Create a picklist with the desired items. These items define object entry states. See Creating a Picklist for more detailed steps.
You can add, remove, or edit picklist items for both draft and published object definitions at any time.
Open the Global Menu (), click the Control Panel tab, and go to Objects.
Begin editing the desired custom object.
Go to the Fields tab and click the Add button ().
Enter a Label and Field Name.
Select the Picklist type and choose the desired list.
Toggle Mark as State.
State fields are automatically set to mandatory, and you cannot change them to optional.
Select a Default Value for the state field.
After adding the field to a definition, you can set up a flow to determine which transitions are available for each state.
Setting Up a Flow for State Fields¶
By default, each state can transition to all other states. However, you can restrict transitions to ensure the entry goes through the desired process.
Follow these steps to set up a custom flow for state fields:
While editing a custom object, go to the State Manager tab and select the desired state field.
Under Next Status, click the drop-down menus and check the boxes to determine available transitions for each state.
You can select any number of transitions for a state.
Once saved, users can only transition an entry’s state according to your defined flow.