Workflow Select field

AttributeDescriptionRequired
label

The text is shown as a label in the user interface.

true

name

Unique field identifier.

Two areas can't have the same name in the exact task definition. The name must be unique.

true

type

Type value. Allowed types:

  • simple ( single choice allowed ).
  • multiple ( multiple selections allowed ).
true
table

Metadata table name.

The application can store values in a metadata table that can be used in this query.

*

width

The width of the HTML element.

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

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

height

The height of the HTML element. false

optionsQuery

A metadata query or SQL query is used to get the select options. *

className

A class is used to get the select options. *

data

When present, it is an identifier used to load data. false

optionsData

When present, it is an identifier used to load options.

false
readonly The set field cannot be modified in the user interface. By default, the value is "false". false

Child elements:

  • Option. Couples 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"/> in the case is set some hierarchical relationship.
  • Validator. For more information, see the Workflow Validator element.

* There're three options to get option values:

  • Directly defined in XML.
  • Metadata table ( table + optionsQuery ).
  • className.

One of these options must be defined. Otherwise, you will get an error. A combination of several cannot be done; 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

We can also get these option values using a SQL query. This SQL sentence should be put on the optionsQuery attribute, but the table attribute should be empty (otherwise, this query is a metadata query). Note that the first element returned in every 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 help get a list from external applications or other purposes, you can build your class to retrieve from these systems the option values.

<?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="okp:consulting.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 relation with "parentSelect." It's defined by parentElement="parentSelect."
  • The option value "benefits" of the field "childrenSelect" has a parent value "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="elegibility" 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

We use a couple of tables to get the information in this case.

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

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

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


insert into UBICACION (UBI_ID, UBI_LOC, UBI_NAME) values ('u0', 'l0', 'Ubicación 0');
insert into UBICACION (UBI_ID, UBI_LOC, UBI_NAME) values ('u1', 'l0', 'Ubicación 1');
insert into UBICACION (UBI_ID, UBI_LOC, UBI_NAME) values ('u2', 'l0', 'Ubicación 2');
insert into UBICACION (UBI_ID, UBI_LOC, UBI_NAME) values ('u3', 'l1', 'Ubicación 4');
insert into UBICACION (UBI_ID, UBI_LOC, UBI_NAME) values ('u4', 'l1', 'Ubicación 5');
insert into UBICACION (UBI_ID, UBI_LOC, UBI_NAME) values ('u5', 'l1', 'Ubicación 6');
insert into UBICACION (UBI_ID, UBI_LOC, UBI_NAME) values ('u6', 'l2', 'Ubicación 7');
insert into UBICACION (UBI_ID, UBI_LOC, UBI_NAME) values ('u7', 'l2', 'Ubicación 8');
insert into UBICACION (UBI_ID, UBI_LOC, UBI_NAME) values ('u8', 'l2', 'Ubicación 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="localidad" label="Localidad"
optionsQuery="select LOC_ID, LOC_NAME from LOCALIDAD" /> <select name="ubicacion" label="Ubicacion" parentElement="localidad"
optionsQuery="select UBI_ID, UBI_NAME, UBI_LOC from UBICACION" /> </workflow-form> </workflow-forms>