cancel
Showing results for 
Search instead for 
Did you mean: 

Default values for Activiti form properties

thilo_ginkel
Champ in-the-making
Champ in-the-making
Hi there,

we are using Activiti's FormService to attach custom form properties to tasks, e.g.:


    <userTask id="usertask1" name="Task 1"" activiti:candidateGroups="Group">
      <extensionElements>
        <activiti:formProperty id="someProperty" name="Some Property" type="boolean" required="true" readable="true" writable="true"></activiti:formProperty>
      </extensionElements>
    </userTask>
What I would like to do, though, is to initialize the property with a default value in case no variable someProperty has been created in the process context so far.

I tried attaching an expression to the property, but this variant does not work as Activity will attempt an assignment to the expression on save, which will obviously fail:


    <userTask id="usertask1" name="Task 1"" activiti:candidateGroups="Group">
      <extensionElements>
        <activiti:formProperty id="someProperty" name="Some Property" type="boolean" required="true" readable="true" writable="true" expression="${false}"></activiti:formProperty>
      </extensionElements>
    </userTask>
org.activiti.engine.impl.javax.el.ELException: Cannot set value of a non-lvalue expression 'false'
   at org.activiti.engine.impl.juel.AstRightValue.setValue(AstRightValue.java:53)
   at org.activiti.engine.impl.juel.AstEval.setValue(AstEval.java:86)
   at org.activiti.engine.impl.juel.TreeValueExpression.setValue(TreeValueExpression.java:138)
   at org.activiti.engine.impl.delegate.ExpressionSetInvocation.invoke(ExpressionSetInvocation.java:37)
   at org.activiti.engine.impl.delegate.DelegateInvocation.proceed(DelegateInvocation.java:37)
   at org.activiti.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocation(DefaultDelegateInterceptor.java:25)
   at org.activiti.engine.impl.el.JuelExpression.setValue(JuelExpression.java:69)
   … 118 more
Now I thought about adding some kind of default expression that is used to initialize a form property iff the backing variable does not yet exist in the current execution scope.

What are your thoughts about this? If you think that this makes sense I would go ahead and contribute a patch…

Regards,
Thilo
12 REPLIES 12

micharg
Champ in-the-making
Champ in-the-making
I think activiti-bpmn-extensions-5.x.xsd needs also updating to support the attribute default.

ddeligeo
Champ in-the-making
Champ in-the-making
Hey guys, is this feature broken again for StartEvent forms?  I'm pretty new to Activiti, and have only used version 5.19, but I'm currently not able to retrieve the default value of a string form property associated with the StartEvent of a yet-to-be instantiated process definition.  I also notice that, when I start the process directly through Explorer, the value is not defaulted in the form field.  Seems to work fine for UserTasks, though.  Of note, but probably not related, is that I'm only using the ReST API to interact with Activiti.

Thanks.

jbarrez
Star Contributor
Star Contributor
A unit test or a combination of REST calls where you can see it going wrong would help here.
I don't know anything broken in this area … but you never know of course.