Workflow Select field

AttributeDescriptionRequired
label

The text shown as a label in the user interface.

true

name

Unique field identifier.

Two fields cannot have the same name in the same task definition. The name must be unique.

true

type

Type value. Allowed types:

  • simple (single choice allowed, default).
  • multiple (multiple selections allowed).
false

value

Can specify a default value for this component.

false

width

The width of the HTML element.

In the case of KCenter, the UI must use width values based on %, for example:

  • width="50%" will work
  • width="100px" will be ignored in the KCenter UI.
false

description

General description.

false

optionsQuery

A SQL query used to retrieve the select options. The first column in the result is the option value; the second is the option label. *

className

A Java class used to retrieve the select options. *

data

When present, an identifier used to dynamically load the selected value. false

optionsData

When present, an identifier used to dynamically load the option list.

false
readonly When true, the field cannot be modified in the user interface. Default is false. false

Child elements:

  • Option. Pairs of XML <option label="label text" value="unique identifier value"/> values or <option label="label text" value="unique identifier value" parentValue="parent unique identifier value"/> when a hierarchical relationship is set.
  • Validator. For more information, see the Workflow Validator element.

* There are three mutually exclusive ways to source option values:

  • Directly defined in XML as <option> elements.
  • SQL query via optionsQuery.
  • Custom Java class via className.

One of these options must be defined. Otherwise, you will get an error. A combination of several cannot be used; only one can be chosen.

Basic select example

  • Type is equal to simple.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE workflow-forms PUBLIC "-//OpenKM//DTD Workflow Forms 2.13//EN"
                                "http://www.openkm.com/dtd/workflow-forms-2.13.dtd">
<workflow-forms>
  <workflow-form task="select test">
    <select label="select label" name="select" type="simple">
      <option label="one" value="001" />
      <option label="two" value="002" />
      <option label="three" value="003" />
    </select>
  </workflow-form>
</workflow-forms>

Allow multiple choice

  • Type is equal to multiple.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE workflow-forms PUBLIC "-//OpenKM//DTD Workflow Forms 2.13//EN"
                                "http://www.openkm.com/dtd/workflow-forms-2.13.dtd">
<workflow-forms>
  <workflow-form task="select test">
    <select label="select label"  name="select" type="multiple" >
      <option label="one" value="001"  />
      <option label="two" value="002"  />
      <option label="three" value="003"  />
    </select>
  </workflow-form>
</workflow-forms>

Based on SQL query

Option values can also be retrieved using a SQL query placed in the optionsQuery attribute. The first column in each row is the option value, and the second is the option label.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE workflow-forms PUBLIC "-//OpenKM//DTD Workflow Forms 2.6//EN"
                                "http://www.openkm.com/dtd/workflow-forms-2.6.dtd">
<workflow-forms>
  <workflow-form task="select test">
    <select label="country" name="country" type="simple"
            optionsQuery="select CT_ID, CT_NAME from COUNTRY order by CT_NAME"/>
  </workflow-form>
</workflow-forms>

The table used in this sample is defined as follows:

create table COUNTRY (
  CT_ID varchar(2),
  CT_NAME varchar(32),
  primary key(CT_ID)
);

insert into COUNTRY (CT_ID, CT_NAME) values ('es', 'Spain');
insert into COUNTRY (CT_ID, CT_NAME) values ('pt', 'Portugal');
insert into COUNTRY (CT_ID, CT_NAME) values ('it', 'Italy');

Based on className

To retrieve a list from external applications or for other purposes, you can build a class to obtain the option values from those systems.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE workflow-forms PUBLIC "-//OpenKM//DTD Workflow Forms 2.6//EN"
                                "http://www.openkm.com/dtd/workflow-forms-2.6.dtd">
<workflow-forms>
  <workflow-form task="select test">
    <select label="select label" name="select" type="simple"
            className="com.openkm.plugin.form.values.OptionSelectUserList" />
  </workflow-form>
</workflow-forms>

For more information, read: Creating your own Option Select Values plugin.

Hierarchical relationship

  • The field option value of "childrenSelect" has a parent relationship with "parentSelect." It's defined by parentElement="parentSelect."
  • The option value "benefits" of the field "childrenSelect" has a parent value of "directives" from the area "parentSelect".

Tree relationships:

  • directives
    • benefits
    • eligibility
    • services
  • handbook
    • basic
    • normal
    • advanced
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE workflow-forms PUBLIC "-//OpenKM//DTD Workflow Forms 2.13//EN"
                                "http://www.openkm.com/dtd/workflow-forms-2.13.dtd">
<workflow-forms>
  <workflow-form task="select test">
    <select label="Parent" name="parentSelect" type="simple">
      <option value="directives" label="Directives" />
      <option value="handbook" label="Handbook Paragraphs" />
    </select> 
    <select label="Children" name="childrenSelect" type="simple" parentElement="parentSelect">
      <option value="benefits" label="Benefits" parentValue="directives" />
      <option value="eligibility" label="Eligibility" parentValue="directives" />
      <option value="services" label="Services" parentValue="directives" />
      <option value="basic" label="Basic" parentValue="handbook" />
      <option value="normal" label="Advanced" parentValue="handbook" />
      <option value="advanced" label="Normal" parentValue="handbook" />
    </select>
  </workflow-form>
</workflow-forms>

Hierarchical relationship with SQL

The following example uses two related tables to populate hierarchical select fields.

create table LOCATION (
  LOC_ID varchar(8),
  LOC_NAME varchar(32),
  primary key (LOC_ID)
);

create table SUBLOCATION (
  UBI_ID varchar(8),
  UBI_LOC varchar(8),
  UBI_NAME varchar(32),
  primary key (UBI_ID)
);

insert into LOCATION (LOC_ID, LOC_NAME) values ('l0', 'Location 0');
insert into LOCATION (LOC_ID, LOC_NAME) values ('l1', 'Location 1');
insert into LOCATION (LOC_ID, LOC_NAME) values ('l2', 'Location 2');

insert into SUBLOCATION (UBI_ID, UBI_LOC, UBI_NAME) values ('u0', 'l0', 'Sub-location 0');
insert into SUBLOCATION (UBI_ID, UBI_LOC, UBI_NAME) values ('u1', 'l0', 'Sub-location 1');
insert into SUBLOCATION (UBI_ID, UBI_LOC, UBI_NAME) values ('u2', 'l0', 'Sub-location 2');
insert into SUBLOCATION (UBI_ID, UBI_LOC, UBI_NAME) values ('u3', 'l1', 'Sub-location 4');
insert into SUBLOCATION (UBI_ID, UBI_LOC, UBI_NAME) values ('u4', 'l1', 'Sub-location 5');
insert into SUBLOCATION (UBI_ID, UBI_LOC, UBI_NAME) values ('u5', 'l1', 'Sub-location 6');
insert into SUBLOCATION (UBI_ID, UBI_LOC, UBI_NAME) values ('u6', 'l2', 'Sub-location 7');
insert into SUBLOCATION (UBI_ID, UBI_LOC, UBI_NAME) values ('u7', 'l2', 'Sub-location 8');
insert into SUBLOCATION (UBI_ID, UBI_LOC, UBI_NAME) values ('u8', 'l2', 'Sub-location 9');

This is the form definition:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE workflow-forms PUBLIC "-//OpenKM//DTD Workflow Forms 2.13//EN"
                                "http://www.openkm.com/dtd/workflow-forms-2.13.dtd">
<workflow-forms>
  <workflow-form task="task">
    <!-- Parent-child -->
    <select name="location" label="Location"
            optionsQuery="select LOC_ID, LOC_NAME from LOCATION" />
    <select name="sublocation" label="Sub-location" parentElement="location"
            optionsQuery="select UBI_ID, UBI_NAME, UBI_LOC from SUBLOCATION" />
  </workflow-form>
</workflow-forms>