AnsweredAssumed Answered

Java Script in Activiti

Question asked by larsson7 on Oct 4, 2012
Latest reply on Jul 23, 2013 by ankit1
Good morning everyone!


I have a problem, i desinged a simple workflow where the status of webcontent ist directly converted into the approves status. But it doesn´t work. Here is my javascript that i wrote: I want to catch the ID of a User and when this user makes a post, the web content should be directly approved.

<scriptTask id="scripttask1" name="Approve" scriptFormat="javascript">
<script><![CDATA[import com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil;
import com.liferay.portal.service.UserLocalServiceUtil;

user = Packages.com.liferay.portal.service.UserLocalServiceUtil.fetchUser(10382);

roles = user.getRoleIds();
status = "Deny";
for (i = 0; i < roles.length; i++) {
if (roles == 15) {
status = "Approve";
break;
}
}

WorkflowStatusManagerUtil.updateStatus(Packages.com.liferay.portal.kernel.workflow.WorkflowConstants.toStatus(status), workflowContext); ]]></script>
</scriptTask>

But i get the following error:

14:15:51,816 INFO [http-bio-8080-exec-5][WorkflowDefinitionManagerImpl:58] Try to deploy process DirectApprove
14:15:51,872 INFO [http-bio-8080-exec-5][WorkflowDefinitionManagerImpl:107] Process DirectApprove deployed with deployment ID 1516
14:15:51,873 INFO [http-bio-8080-exec-5][WorkflowDefinitionManagerImpl:109] 1 process definitions deployed
14:15:51,873 INFO [http-bio-8080-exec-5][WorkflowDefinitionManagerImpl:122] Process Definition Id for process process1 : process1:6:1519
14:16:02,323 ERROR [http-bio-8080-exec-7][WorkflowComparatorFactoryImpl:18] Method is not implemented
14:16:07,900 ERROR [http-bio-8080-exec-7][WorkflowComparatorFactoryImpl:18] Method is not implemented
14:16:24,158 INFO [http-bio-8080-exec-3][WorkflowInstanceManagerImpl:194] Start workflow instance process1 : 6
14:16:24,426 ERROR [http-bio-8080-exec-3][render_portlet_jsp:154] org.activiti.engine.ActivitiException: problem evaluating script: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "workflowContext" is not defined. (<Unknown source>#13) in <Unknown source> at line number 13
at org.activiti.engine.impl.scripting.ScriptingEngines.evaluate(ScriptingEngines.java:71)
at org.activiti.engine.impl.bpmn.behavior.ScriptTaskActivityBehavior.execute(ScriptTaskActivityBehavior.java:51)


Why is workflow context undefiened??

Thanks for your help!!!

Best Regards, Philipp

Outcomes