Add a comment to a WorkflowInstance (Liferay 7.1.10-fp6)

Dominik Grob, modified 6 Years ago. New Member Posts: 5 Join Date: 11/10/17 Recent Posts
Hi all

I basically try to add a comment to a workflow instance. This comment should be independent from a task assignment or completion. The reviewer should always be able to add a comment to a WorkflowInstance and view all comments. The reviewer has no control panel access.

I see two ways to do it:

Rebuild MyWorkflowTaskPortlet and use the liferay-comment:discussion taglib
Unfortunately I always receive a 500 from the server when I add a new comment. And available comments were not displayed. Maybe I use the taglib wrong, but I guess it does not work because I start the workflow programmatically (WorkflowInstanceManagerUtil.startWorkflowInstance()) and I dont assign a classPK to the WorkflowInstance respectively add to the workflowContext.

Add a line in the KaleoLog
Its easy to read the KaleoLog with the WorkflowLogManagerUtil() but I was not able to add a line. I tried WorkflowTaskManagerUtil.updateDueDate() but this method does not update the database. I am wondering what the usage of this method really is. Its never used in the sources.

Thanks for your help
Dominik
thumbnail
Amos Fong, modified 6 Years ago. Liferay Legend Posts: 2047 Join Date: 10/7/08 Recent Posts
Hi Dominik,

Add a line in the KaleoLog
I've done this via groovy script in the workflow definition like so:
​​​​​​​<action>
    <name>approved</name>
    <script>
        <![CDATA[
            import com.liferay.portal.kernel.util.GetterUtil;
            import com.liferay.portal.kernel.workflow.WorkflowConstants;
            import com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil;
            import com.liferay.portal.kernel.model.User;
            import com.liferay.portal.workflow.kaleo.service.KaleoLogLocalServiceUtil;

            WorkflowStatusManagerUtil.updateStatus(WorkflowConstants.STATUS_APPROVED, workflowContext);

            kaleoLog = KaleoLogLocalServiceUtil.addNodeExitKaleoLog(kaleoInstanceToken, kaleoInstanceToken.getCurrentKaleoNode(), serviceContext);

            kaleoLog.setCurrentAssigneeClassName(User.class.getName());
            kaleoLog.setCurrentAssigneeClassPK(GetterUtil.getLong(userId));
            kaleoLog.setPreviousKaleoNodeName("review");

            KaleoLogLocalServiceUtil.updateKaleoLog(kaleoLog);
        ]]>
    </script>
    <script-language>groovy</script-language>
    <execution-type>onEntry</execution-type>
</action>

Hope that helps you figure out a solution