Description
This function is called from the skeleton processor to populate the options controls of form fields (eg the radio group) with values. The dbdetails object contains many optional fields which may be required dependent on the values of other fields. You may either:
Provide an SQL statement that selects DataValue, DataDisplay and optionally DataGroup from a table in the iCM database.
OR
Provide values for (at least) the table, value and display properties so that an SQL statement may be auto generated.
Parameters
Name | Type | Description |
---|---|---|
fieldname | String, required | The name of the field to be populated with the returned options |
maxnumresults | Integer, optional | The number of results to return |
queryTimeout | Integer, optional | A number of seconds to set as the timeout for the query. If not set will default to the queryTimeout set at the worker config level (which itself defaults to 120) |
dbdetails | Object, required | The details of the database query |
dbdetails.table | String, required | The table that will supply the optionData |
dbdetails.value | String, required | The column that will supply the optionData values |
dbdetails.display | String, required | The column that will supply the optionData display text |
dbdetails.group | String, optional | Default "" The column that will supply the optionData groups |
dbdetails.orderby | String, optional | Default "" The column to order the optionData by |
dbdetails.orderbydir | String (enumeration), optional | Default "ASC" The direction of the ordering, "ASC" = ascending or "DESC" = descending |
dbdetails.datasource | String, optional | Default "" (the iCM database) The datasource to be queried |
Alternatively you can write an explicit SQL statement:
Name | Type | Description |
---|---|---|
fieldname | String, required | The name of the field to be populated with the returned options |
dbdetails | Object, required | The details of the database query |
dbdetails.sql | String (SQL), required | An SQL statement |
dbdetails.datasource | String, optional | Default "" (the iCM database) The datasource to be queried |
Example
This example queries the article table of the iCM database..
function(params, credentials) {
let request = this.callWorkerMethod( 'formutils', 'doOptionDataRead', {
"fieldname": "FIELD1",
"maxnumresults": 10,
"dbdetails": {
"table": "Article",
"value": "ArticleID",
"display": "ArticleHeading",
"orderby": "ArticleID",
"orderbydir": "ASC"
}
});
return request;
}
Or, using sql:
function(params, credentials) {
let request = this.callWorkerMethod( 'formutils', 'doOptionDataRead', {
"fieldname": "FIELD1",
"dbdetails":{
"sql":"SELECT TOP 10 [ArticleID] as DataValue, [ArticleHeading] as DataDisplay FROM Article ORDER BY [ArticleID] ASC"
}
});
return request;
}
Result
{
"id": 41,
"result": [
["1", "Welcome to the GOSS Docs Site", ""],
["2", "Hidden Articles", ""],
["3", "Top Utils", ""],
["4", "Bottom Utils", ""],
["1703", "The Commerce Platform", ""],
["1704", "iCM Management", ""],
["1706", "System Configuration", ""],
["1709", "Events", ""],
["1710", "Features", ""],
["1711", "The Forms Designer", ""]
],
"jsonrpc": "2.0"
}