User input request

Sample

Now we will create a workflow which needs some data from user. This is the workflow graph:

And this is the workflow definition:

<?xml version="1.0" encoding="UTF-8"?>
<process-definition  xmlns="urn:jbpm.org:jpdl-3.2"  name="UserInput">
  <start-state name="start">
    <transition to="PlaceOrder" name="trPlaceOrder"></transition>
  </start-state>
  <task-node name="PlaceOrder">
    <task name="MyTask">
      <assignment actor-id="tazplat"></assignment>
      <controller></controller>
    </task>
    <transition to="CheckAvailability"></transition>
  </task-node>
  <decision name="CheckAvailability" expression="#{(amount&gt;100)?'trNotAvailable':'trAvailable'}">
    <transition to="end" name="trAvailable"></transition>
    <transition to="sendMail" name="trNotAvailable"></transition>
  </decision>
  <mail-node name="sendMail" to="stock@your-domain.com">
    <subject>We need more product</subject>
    <text>There is no product, so we must to buy more units!</text>
    <transition to="end"></transition>
  </mail-node>
  <end-state name="end"></end-state>
</process-definition>

And this is the form for the user input value:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE workflow-forms PUBLIC "-//OpenKM//DTD Workflow Forms 2.0//EN"
                                "http://www.openkm.com/dtd/workflow-forms-2.0.dtd">
<workflow-forms>
  <workflow-form task="MyTask">
    <input label="Amount" name="amount" />
    <button label="Submit" />
  </workflow-form>
</workflow-forms>

This process definition has a task node (with a task called "MyTask") which is assigned to the user "tazplat". You should change this user to meet an existing user in you OpenKM installation. The user has to enter a value for the amount variable. This value is evaluated in the CheckAvailability decision node by this expression:

#{(amount.value>100)?'trNotAvailable':'trAvailable'}

And depending on the requested value, the flow will go across the sendMail mail node or directly to the end state.

Once the process definition is deployed in OpenKM, any user can start the workflow. When the the user input is required, a mail is sent to the user "tazplat". He should log into OpenKM web interface and will see something like this notification:

If he click on this icon, the view will switch to the dashboard. Select the task listed at Pending tasks and he will see the details. In the data section are displayed the variables attached to this process instance: an unmodifiable one called Path which describe the associated document, and an input called Amount where the user can enter a quantity.