Description
Workflows on Liferay give the possibility of running assets like web content articles, wiki pages, or even users, through pre-determined review processes. For this you can utilize workflow statuses.
Let's say, you, as an Administrator, want to have control over all the comments that are made in a single blog post. For that, you could setup a workflow definition of your choice that every comment will have to go through before being approved and finally published. So, when you create that review process using Liferay's Workflow, you must define steps that assign statuses to these incoming comments in order to determine the acceptance, or rejection, criteria for them (ie: denied, pending, incomplete, etc.).
Resolution
Liferay gives a set of statuses, "out-of-the-box", which you can find listed below or in our code's repository. A supported status must be used and be set correctly otherwise, your workflow definition might fail to process the assets as you intended.
Here is an example of how to update the status correctly:
<script> <![CDATA[ import com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil; import com.liferay.portal.kernel.workflow.WorkflowConstants; WorkflowStatusManagerUtil.updateStatus(WorkflowConstants.getLabelStatus("approved"), workflowContext); ]]> </script> <script-language>groovy</script-language>
Note: If you misspell the status label like in the following, the asset will be set to status "any" by default:
<script> <![CDATA[ import com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil; import com.liferay.portal.kernel.workflow.WorkflowConstants; WorkflowStatusManagerUtil.updateStatus(WorkflowConstants.getLabelStatus("approve"), workflowContext); ]]> </script> <script-language>groovy</script-language>
List of Supported Workflow Statuses
- "any";
- "approved";
- "denied";
- "draft";
- "expired";
- "in-trash";
- "inactive";
- "incomplete";
- "pending";
- "scheduled";
Additional Information
For more information on how you can leverage Liferay's script engine to enhance the Workflow experience. please see: Leveraging the Script Engine in Workflow.