Metadata Suggestbox field

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

AttributeDescriptionRequired
label

The text shown as a label in the user interface.

true

name

Unique field identifier.

Two metadatas can't have the same name. Name must be unique.

The name must start with "okp:".

It's a good practice to use a metadata group name as basis for metadata field name. For example use "okg:consulting" has been used for field name "okp:consulting.suggestbox", changin "okg" to "okp". That helps to find out the metada group based on metadata field name.

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

true

width

The width of the HTML element. false

height

The height of the HTML element. false

description

General description. false

filterQuery

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

valueQuery

A SQL query to obtain the value of a identifier. Use {0} to place the identifier. *

className

A class used to get the selected options. *

filterMinLen

The minimum chars in input to begin to filter results. true
dialogTitle

The title of the HTML dialog.

true

readonly

The set field will not be able to 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 128 characters size. Because your data length might be bigger than 128 characters the administrator should update the default column size.

Take a look at Metadata XML definition documentation section for a deep explanation about metadata storage in OpenKM database,

 

Child elements:

* There're three options to get suggestbox values ( use one of them is mandatory ):

  • filterQuery + valueQuery
  • className

No other combination of them is allowed.

Based on filterQuery and valueQuery

Now filterQuery and valueQuery could be a regular SQL query. 

You should only use {0} as the parameter entered by the user 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.7//EN"
                                 "http://www.openkm.com/dtd/property-groups-3.7.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 to get a list from external applications or other purposes, your own class can be built to retrieve the option values from those systems.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 3.7//EN"
                                 "http://www.openkm.com/dtd/property-groups-3.7.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