Message Boards

How to trigger workflow action for WebContent from Java

shweta tiwari, modified 7 Years ago.

How to trigger workflow action for WebContent from Java

New Member Posts: 2 Join Date: 4/15/16 Recent Posts
I am using Liferay 6.2
And designing a customized workflow UI from which i will be editing the web content and will send for approval.
So i wanted to ask if we can trigger workflow actions on Web Content from Java
thumbnail
Aravinth Kumar, modified 7 Years ago.

RE: How to trigger workflow action for WebContent from Java

Regular Member Posts: 152 Join Date: 6/26/13 Recent Posts
Yes to start workflow process you can use

WorkflowHandlerRegistryUtil.startWorkflowInstance(journal.getCompanyId(), journal.getUserId(), JournalArticle.class.getName(), journal.getClassPK(), journal, serviceContext);
shweta tiwari, modified 7 Years ago.

RE: How to trigger workflow action for WebContent from Java

New Member Posts: 2 Join Date: 4/15/16 Recent Posts
Thanks Aravinth for your reply.

Below is the code which i am calling to update the journal article and start the workflow.
But journal article is getting updated with status as approved instead of Pending.
The use case i am trying to achieve is .. user will updated the web content and submit it for approval.
In this flow new task should get created in pending status and assigned to any reviewer.
Can you please tell me how to achieve this.



journalArticle = JournalArticleLocalServiceUtil.updateJournalArticle(updatedJournalArticle);  

ServiceContext serviceContext = new ServiceContext();
serviceContext.setScopeGroupId(themeDisplay	.getScopeGroupId());
serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT); 
WorkflowHandlerRegistryUtil.startWorkflowInstance(
							journalArticle.getCompanyId(),
							journalArticle.getUserId(),
							JournalArticle.class.getName(),
							journalArticle.getClassPK(), journalArticle,
							serviceContext);