cancel
Showing results for 
Search instead for 
Did you mean: 

activity:formProperty predefined value

artur_karczmarc
Champ in-the-making
Champ in-the-making
Hi,

I've created a process definition using Activiti Eclipse BPMN 2.0 Designer 5.7.0. The process definition contains a following user task:


<userTask id="UT1" name="User task name" activiti:candidateGroups="GROUP_ADMIN">
   <extensionElements>
      <activiti:formProperty id="url" name="url" type="string" variable="abc" required="true" readable="true" writable="true">
      </activiti:formProperty>
   </extensionElements>
</userTask>

Although I set the value parameter (value="abc") of the formProperty url in the activiti designer, and as you see in the code above the variable parameter is set to "abc", when I execute the following code in my app:


TaskQuery taskQuery = activitiTaskService.createTaskQuery();
List<Task> qtasks = taskQuery.list();
Assert.assertTrue(qtasks.size() > 0);
Task task1 = qtasks.get(0);
List<FormProperty> formProperties = activitiService.getFormService().getTaskFormData(task1.getId()).getFormProperties();
Assert.assertNotNull(formProperties.get(0).getValue());

the last assertion fails. Can anyone show me what I am doing wrong? Is it possible to create a process with a predefined form property value?

In my app I am going to create the bpmn20.xml file dynamically and then parse it, deploy and run. Every usertask in the process is going to contain title and an URL to some action on the website. Optionally, it will also contain some description. Then the task assignee will read the description, click on the link and be redirected to the URL. I somehow need to inject the URL to the usertask during the dynamic creation of the bpmn20.xml file. Any ideas how to do it, in case the above idea with activiti:formProperty fails?
1 REPLY 1

ruben1
Champ in-the-making
Champ in-the-making
Hi Artur,

I discovered the same. It looks like the designers 'value' field is actually _not_ a value for the FormProperty but the name of the ProcessVariable to map the FormProperty to. If you want to set default values or to predefine process vars insert a script task which sets them. Works for me atm.

(Eclipse Designer in the Properties of the Script Task in 'Main Config' => Script Language is set to 'javascript')


execution.setVariable('name', 'value');
results in

    <scriptTask id="scripttask1" name="Script Task" scriptFormat="javascript">
      <script><![CDATA[execution.setVariable("name", "value")]]></script>
    </scriptTask>


After task completion you'll have a process var with name 'name' and value 'value'.

see http://activiti.org/userguide/index.html#bpmnScriptTask

Ruben