User input request

From OpenKM Documentation
Jump to: navigation, search

Now we will create a workflow which need 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=""  name="UserInput">
  <start-state name="start">
    <transition to="PlaceOrder" name="trPlaceOrder"></transition>
  <task-node name="PlaceOrder">
    <task name="MyTask">
      <assignment actor-id="tazplat"></assignment>
    <transition to="CheckAvailability"></transition>
  <decision name="CheckAvailability" expression="#{(amount&gt;100)?'trNotAvailable':'trAvailable'}">
    <transition to="end" name="trAvailable"></transition>
    <transition to="sendMail" name="trNotAvailable"></transition>
  <mail-node name="sendMail" to="">
    <subject>We need more product</subject>
    <text>There is no product, so we must to buy more units!</text>
    <transition to="end"></transition>
  <end-state name="end"></end-state>

And this is the form for the user input value (for more info read Workflow Forms description):

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

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 have to enter a value for the amount variable. This value is evaluated in the CheckAvailability decision node by this expression:


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.