Search code examples
camunda

Can't get process start variables


I'm trying to get process start variables via rest, but I can't receive any start variable.

When i try:

http://192.168.30.1:8080/engine-rest/process-definition/key/invoice/form-variables

I got only this:

{}

How to get process start variables?


Solution

  • Thats because the resource Get Start Form Variables only supports Generated Start Forms.

    The invoice process uses Embedded Start Form. The start event of the invoice process references an external HTML file, which is used to render the Start form.

    See here:

    <startEvent id="StartEvent_1" name="Invoice&#10;received" camunda:formKey="embedded:app:forms/start-form.html">
      <outgoing>SequenceFlow_1</outgoing>
    </startEvent>
    

    If you want to receive the start form variables, the start event of the process must be look like the following example:

    <startEvent id="start">
      <extensionElements>
        <camunda:formData>
          <camunda:formField id="stringField" label="String Field" type="string" defaultValue="someString">
            <camunda:validation>
              <camunda:constraint name="maxlength" config="10" />
              <camunda:constraint name="minlength" config="5" />
            </camunda:validation>
          </camunda:formField>
          <camunda:formField id="longField" label="Long Field" type="long" defaultValue="5">
            <camunda:validation>
              <camunda:constraint name="max" config="10" />
              <camunda:constraint name="min" config="3" />
            </camunda:validation>
          </camunda:formField>
          <camunda:formField id="customField" label="Custom Field" type="string">
            <camunda:validation>
              <camunda:constraint name="validator" config="org.camunda.bpm.engine.test.api.form.CustomValidator" />
            </camunda:validation>
          </camunda:formField>
          <camunda:formField id="dateField" label="Date Field" type="date" defaultValue="10/01/2013" />
        </camunda:formData>
      </extensionElements>
    </startEvent>
    

    See here for the complete example process. In that case the FormService can resolve the form variables and the request will return the defined variables.