cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Forms with Form Key Attribute

smee82
Champ in-the-making
Champ in-the-making
Hey guys,

i want to have dynamic forms for my tasks. I think i'm not really getting the idea of the user so guide. So i tried the following:

in my bpmn process file:
….
<process id="TheFlexibleFrog" name="TheFlexibleFrog">
    <documentation>Test a froggy dynamic dropdown menu.</documentation>
    <startEvent id="startevent1" name="Start"></startEvent>
    <endEvent id="endevent1" name="End"></endEvent>
    <userTask id="dynamic_dropdown" name="Dynamic Dropdown" activiti:assignee="kermit" activiti:formKey="main/resources/diagrams/FlexForm.xml"></userTask>
    <sequenceFlow id="flow1" name="" sourceRef="startevent1" targetRef="dynamic_dropdown"></sequenceFlow>
    <sequenceFlow id="flow2" name="" sourceRef="dynamic_dropdown" targetRef="endevent1"></sequenceFlow>
  </process>
…..

in an extra xml-file which i deloyes on my activi:
<?xml version="1.0" encoding="UTF-8"?>
<extensionElements>
        <activiti:formProperty id="no_frogs" name="Anzahl Frösche" type="long" variable="0" required="true" readable="true" writable="true"></activiti:formProperty>
        <activiti:formProperty id="zubereitungsart" name="Zubereitungsart" type="enum" required="true" readable="true" writable="true">
          <activiti:value id="gebraten" name="gebraten"></activiti:value>
          <activiti:value id="gekocht" name="gekocht"></activiti:value>
          <activiti:value id="frittiert" name="frittiert"></activiti:value>
        </activiti:formProperty>
</extensionElements>

But there are no form properties shown when i execute the process and complete the task.

Hope anyone understands my problem  :roll: Thanks.
10 REPLIES 10

smee82
Champ in-the-making
Champ in-the-making
Ok it seems my problem is a bit confusing. I try it another way.

Can anyone explain me how to use the form key attribute?

Thanks a lot.

trademak
Star Contributor
Star Contributor
Hi,

You should include the form properties in the bpmn20.xml file so:

<userTask id="dynamic_dropdown" name="Dynamic Dropdown" activiti:assignee="kermit">
<extensionElements>
  <activiti:formProperty id="no_frogs" name="Anzahl Frösche" type="long" variable="0" required="true" readable="true" writable="true"></activiti:formProperty>
  <activiti:formProperty id="zubereitungsart" name="Zubereitungsart" type="enum" required="true" readable="true" writable="true">
    <activiti:value id="gebraten" name="gebraten"></activiti:value>
    <activiti:value id="gekocht" name="gekocht"></activiti:value>
    <activiti:value id="frittiert" name="frittiert"></activiti:value>
  </activiti:formProperty>
</extensionElements>
</userTask>

Best regards,

smee82
Champ in-the-making
Champ in-the-making
Yes ok, but i want to have the form properties in an external document (this could be a deployment on activiti, but not inside the process definition bpmn20.xml). So that i can do a reference in my bpmn20.xml to an external document which contains my form properties. The intense is to change the form properties in different contexts and control this by using a processvariable.

smee82
Champ in-the-making
Champ in-the-making
Hi,

You should include the form properties in the bpmn20.xml file so:

<userTask id="dynamic_dropdown" name="Dynamic Dropdown" activiti:assignee="kermit">
<extensionElements>
  <activiti:formProperty id="no_frogs" name="Anzahl Frösche" type="long" variable="0" required="true" readable="true" writable="true"></activiti:formProperty>
  <activiti:formProperty id="zubereitungsart" name="Zubereitungsart" type="enum" required="true" readable="true" writable="true">
    <activiti:value id="gebraten" name="gebraten"></activiti:value>
    <activiti:value id="gekocht" name="gekocht"></activiti:value>
    <activiti:value id="frittiert" name="frittiert"></activiti:value>
  </activiti:formProperty>
</extensionElements>
</userTask>

Best regards,

When i try to deploy this as a file i get: The prefix "activiti" for element "activiti:formProperty" is not bound.

trademak
Star Contributor
Star Contributor
Did you add the following namespace definitions:

<definitions id="example"
   xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:activiti="http://activiti.org/bpmn"
targetNamespace="http://example">

Best regards,

smee82
Champ in-the-making
Champ in-the-making
That doesn't work either. It says userTask is no valid root element.

trademak
Star Contributor
Star Contributor
Hi,

I think it's good if you read through some examples first in the userguide and the Activiti source code.
In addition, the Activiti in Action book provides a lot of extra details.
You're missing the process element that is required.

Best regards,

smee82
Champ in-the-making
Champ in-the-making
Hi,

I think it's good if you read through some examples first in the userguide and the Activiti source code.
In addition, the Activiti in Action book provides a lot of extra details.
You're missing the process element that is required.

Best regards,

This is what the userguide says, there is nothing about what this "my-custom-form.xml" should contain. Thats not quite much, i think.

The attribute <userTask activiti:formKey="…" is exposed by the API through String FormService.getStartFormData(String processDefinitionId).getFormKey() and String FormService.getTaskFormData(String taskId).getFormKey(). You could use this to store the full name of the template within your deployment (eg. org/activiti/example/form/my-custom-form.xml), but this is not required at all. For instance, you could also store a generic key in the form attribute and apply an algorithm or transformation to get to the actual template that needs to be used. This might be handy when you want to render different forms for different UI technologies like e.g. one form for usage in a web app of normal screen size, one form for mobile phone's small screens and maybe even a template for a IM form or an email form.

Thanks for your help.

trademak
Star Contributor
Star Contributor
No that's right, because as the userguide says it's up to you how you want to implement the user task forms when you're using the form key.
You can retrieve the form key value and the XML file corresponding to it via the Activiti API, but then you've to develop the UI logic yourself.

Best regards,