I have just tried the following code (in my process definition) to set the date to the current date. And it worked only once or twice!! It actually changed the variable field in the database with the expected value.
<start-state name="start automatic_date"> <task swimlane="demandeur"> <controller> <variable name="myDate"/> </controller> <event type="task-create"> <script> <expression> Date today = new Date(); executionContext.getContextInstance().setVariable("myDate",today.toString()); </expression> </script> </event> </task> <transition name="" to="task1"> </transition> </start-state> <task-node name="task1"> <task swimlane="demandeur"> <controller> <variable name="myDate"/> </controller> </task> <transition name="" to="end1"></transition> </task-node> <end-state name="end1"></end-state>
executionContext.getContextInstance().setVariable("stv", new Integer(11));
Never mind, i figured out what was missing: you have to make sure the variable is READ-only when declaring it.
<variable name="myDate" access="read" />