Can I set a camunda:formField 'defaultValue' from a Process Instance Variable in the BPMN file?

I have the following formField in my startEvent:
<camunda:formField id=“state” label=“State” type=“enum” defaultValue=“DRAFT”>
<camunda:value id=“DRAFT” name=“DRAFT” />
<camunda:value id=“SUBMITTED” name=“SUBMITTED” />
<camunda:value id=“CLOSED” name=“CLOSED” />
</camunda:formField>

In a subsequent Task, I have the same formField, but I cannot figure out how to have the defaultValue properly set.

For instance:
<camunda:formField id="state" label="State" type="enum" defaultValue="${state}">
does not work. I am using the Camunda Tasklist WebApp.

Is that possible?

Hi there,

do you already have a solution to this problem?
I’m asking, because currently I have the same problem and if you still need a solution, I could post it here after I found it. :wink:

Hi @stefan_geiss,

I double checked it and it worked for me:

grafik

This is the XML snippet from the modeler:

    <bpmn:userTask id="Task_0f8s3co" name="Enter values">
      <bpmn:extensionElements>
        <camunda:formData>
          <camunda:formField id="firstName" label="firstname" type="string" defaultValue="${startUser}" />
        </camunda:formData>
      </bpmn:extensionElements>
      <bpmn:incoming>SequenceFlow_1slneyk</bpmn:incoming>
      <bpmn:outgoing>SequenceFlow_13cyyv4</bpmn:outgoing>
    </bpmn:userTask>

Hope this helps, Ingo

1 Like

Thank you very much for the reply.
I found out that we use a custom adjusted logic to create the forms from the camunda BPMN model.
So I extended this logic to fit my needs. :slight_smile:

Hey @Ingo_Richtsmeier,

I have the exact same question as knotthere, and i’m not clarified yet.
I think he asked about a default value in a variable of type “enum” and not “string”. I already tested with string and it works, so can i assume that this feature is not enabled for enums?

Thanks

Hi, @knotthere

change the id of enum you are binding to. If you use different id for form field and different id for default value it will work and also use a blank id enum at the beginning.

attached solution:
enumform.bpmn (3.7 KB)