Metadata Suggestbox field

This is an implementation of the typical AJAX suggest box component:

AttributeDescriptionRequired
label

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

true

name

A unique field identifier.

Two metadata fields can't have the same name. The name must be unique.

The name must start with "okp:".

Using a metadata group name as a basis for a metadata field name is a good practice. For example, use "okg:consulting" as the group name; the field name "okp:consulting.suggestbox" is formed by changing "okg" to "okp". That helps to find the metadata group based on the metadata field name.

Please use only letters, numbers, and underscores: "0-9a-zA-Z_".

true

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

filterQuery

A SQL query to filter the data. Use {0} to insert the user input. *

valueQuery

A SQL query to obtain the value of an identifier. Use {0} to insert the identifier. *

className

A class is used to get the selected options. *

filterMinLen

The minimum number of characters in the input to begin filtering results. true
dialogTitle

The title of the HTML dialog.

true

readonly

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

dbColumnSize

Set the size of the database field where the value is stored.

By default, fields are stored in a database column with a size of 128 characters. Because your data length might be greater than 128 characters, the administrator should update the default column size.

Take a look at the Metadata XML definition documentation section for a detailed explanation of metadata storage in the OpenKM database.

 

defaultAccess

Default security access policy. By default, it is set to "grant", so all users will see the property.

 

Child elements:

* There are three options to get suggested box values (using one of them is mandatory):

  • filterQuery + valueQuery
  • className

No other combination is allowed.

Based on filterQuery and valueQuery

Now filterQuery and valueQuery can be regular SQL queries. 

You should only use {0} as the parameter for the user's input to filter the values from the table. 

Create COUNTRY table:

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

Metadata definition:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 3.10//EN"
                                 "http://www.openkm.com/dtd/property-groups-3.10.dtd">
<property-groups>
  <property-group label="Consulting" name="okg:consulting">
	 <suggestbox label="country" name="okp:consulting.suggestbox"
 	 	 width="200px" dialogTitle="Choose country" filterMinLen="3"
	 	 filterQuery="select ct_id, ct_name from COUNTRY where ct_name like '%{0}%' order by ct_name" 
	 	 valueQuery="select ct_id, ct_name from COUNTRY where ct_id='{0}'" />
  </property-group>
</property-groups>

Based on className

To help retrieve a list from external applications or for other purposes, your class can be built to obtain the option values from those systems.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 3.10//EN"
                                 "http://www.openkm.com/dtd/property-groups-3.10.dtd">
<property-groups>
  <property-group label="Consulting" name="okg:consulting">
	 <suggestbox label="country" name="okp:consulting.suggestbox"
 	 	 width="200px" dialogTitle="Choose country" filterMinLen="3"
	 	 className="com.openkm.plugin.form.values.SuggestBoxUserList" />
  </property-group>
</property-groups>

For more information, read Creating your own Suggestbox plugin