cancel
Showing results for 
Search instead for 
Did you mean: 

formProperty variable, how do you pass a execution variable.

cirerenat
Champ in-the-making
Champ in-the-making
Is it possible to pass a value to formProperty from a variable (and vice versa, that is assigning whatever the value entered in the user task to a execution variable).
I have this flow. It has a Script Task and followed by a User Task.
In the script task (groovy) I have this
myName = "Test Name";
execution.setVariable("myName",myName);

And in the user task I have a formProperty defined as this

 <activiti:formProperty id="name" name="Name" variable="${myName}" required="true" readable="true" writable="true">

When I deploy this to activiti-explorer and run it, I expect to see the Form with
Name = "Test Name". 

But it is null.
What am I doing wrong ?
10 REPLIES 10

krigu
Champ in-the-making
Champ in-the-making
I have exactly the same problem… Is there a solution available?

krigu
Champ in-the-making
Champ in-the-making
<activiti:formProperty id="name" name="Name" variable="${myName}" required="true" readable="true" writable="true">

After i removed the $ and the brackets it worked..

<activiti:formProperty id="name" name="Name" variable="myVarName" required="true" readable="true" writable="true">

cirerenat
Champ in-the-making
Champ in-the-making
Thank you. Yes it worked for me as well. But I still have an issue, Because I had actually simplified my case to post here before.
Some of my process variables are my domain objects. And in the user form, I refer the attributes as domain.attr1, domain.attr2 (I know domain object has already values in attr1 and attr2) the form fields don't show the values.

trademak
Star Contributor
Star Contributor
Hi,

For domain objects / Java objects you can use the expression attribute.

Best regards,

cirerenat
Champ in-the-making
Champ in-the-making
Tijs,
So it is a one-way binding then ? That's the form would display the value from the variable or expression when it is displayed, but what about when the user overrides these values, how would that work with an expression.

Do you have a good example to show using variables and expressions with domain objects? 
Say I have a Person object.
My activiti flow starts with a groovy script task

import com.domain.Person;
Person person = new Person();
person.setName("Person Name");
// Or person.name = "Person Name"
execution.setVariable("person", person );
myName = "Test Name";
execution.setVariable("myName",myName);

The groovy task followed by a UserTask, in that, the form fields are defined like below


Id                  Name               Type           Value/Expression
pname1          Name1                               person.name
pname2          Name2                               ${person.name}
mname           Name3                               myName

Now when I run this,  In the form I see Name3 is shown as "Test Name". But Name1 and Name2 is blank. I am expecting to see "Person Name" in Name2 or Name1.

By the way, should I post this to Activiti Explorer forum maybe?

jbarrez
Star Contributor
Star Contributor
Hi,

No it's a two-way binding actually.
Could you try and use #{person.name} in the expression field?

Best regards,

cirerenat
Champ in-the-making
Champ in-the-making
Yes that notation worked; #{person.name} Smiley Very Happy Thank you

cirerenat
Champ in-the-making
Champ in-the-making
A follow-up question. Is it possible to define the form fields wider. I don't see a property in the activiti designer to control that, if the value of #{person.name} is pretty long, I want to define the form fields wider than the default.

elsarfhem
Champ in-the-making
Champ in-the-making
Hi,

No it's a two-way binding actually.
Could you try and use #{person.name} in the expression field?

Best regards,


Could you explain in detail what's the difference between ${} and #{}, please? I'm not able to understand it starting either from user guide or from my real use-case.
I try ${myvar} in mail task and it worked. But in the following usertask's form I try myvar = ${myvar} and it was blank. instead myvar = #{myvar} works as expected.
Is it due to scope?

edit: I'm speaking about process/form variable, not JPA/Spring objects