Skip to content

Workflow Select field

Attribute Description Required
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 same task definition. The name must be unique.
true
type Type value. Allowed types:
- simple (single choice allowed).
- multiple (multiple selections allowed).
true
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 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. Pairs of XML values or when a hierarchical relationship is set.
  • Validator. For more information, see the Workflow Validator element.

* There are three options to get option values:

  • Directly defined in XML.
  • Metadata table ( optionsQuery ).
  • className.
  • Type is equal to simple.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE workflow-form PUBLIC "-//OpenKM//DTD Workflow Form 1.0//EN"
"https://www.openkm.com/dtd/workflow-form-1.0.dtd">
<workflow-form>
<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>
  • Type is equal to multiple.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE workflow-form PUBLIC "-//OpenKM//DTD Workflow Form 1.0//EN"
"https://www.openkm.com/dtd/workflow-form-1.0.dtd">
<workflow-form>
<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>

We can also get these option values using a SQL query. This SQL statement should be placed in 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-form PUBLIC "-//OpenKM//DTD Workflow Form 1.0//EN"
"https://www.openkm.com/dtd/workflow-form-1.0.dtd">
<workflow-form>
<select label="country" name="country" type="simple"
optionsQuery="select CT_ID, CT_NAME from COUNTRY order by CT_NAME"/>
</workflow-form>

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');

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-form PUBLIC "-//OpenKM//DTD Workflow Form 1.0//EN"
"https://www.openkm.com/dtd/workflow-form-1.0.dtd">
<workflow-form>
<select label="select label" name="select" type="simple"
className="com.openkm.plugin.form.values.OptionSelectUserList" />
</workflow-form>

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

  • 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-form PUBLIC "-//OpenKM//DTD Workflow Form 1.0//EN"
"https://www.openkm.com/dtd/workflow-form-1.0.dtd">
<workflow-form>
<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>

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-form PUBLIC "-//OpenKM//DTD Workflow Form 1.0//EN"
"https://www.openkm.com/dtd/workflow-form-1.0.dtd">
<workflow-form>
<!-- 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>