JavaScript API Reference/Ab.view.View object

View.selectValue (formId, title, targetFieldNames, selectTableName, selectFieldNames, visibleFieldNames, restriction, actionListener, applyFilter,showIndex, workflowRuleId, width, height, selectValueType )

The View.selectValue() parameters can be supplied as a single object with named properties. This format is easier to read in the JS source code, and is recommended for new development.

Example:

ab-products/solutions/parts/form/ab-ex-form-panel-select-value.js

View.selectValue({
formId: 'formPanelSelVal_form',
title: getMessage('titleRequestedBy'),
fieldNames: ['wr.requestor'],
selectTableName: 'em',
selectFieldNames: ['em.em_id'],
visibleFieldNames: ['em.em_ id','em.phone','em.email', 'em.dv_id'],
actionListener: 'afterSelectEmployee',
width: 1000,
height: 500
});

Open a Select Value dialog for a specified form field or fields.

Parameters:

  • formId (String): id attribute of the form panel that contains the field;
  • title (String): (optional) title to be displayed in the select value dialog;
  • targetFieldNames (array): array of full field names of the form fields that are to be selected;
  • selectTableName (String): name of the table to select values from;
  • selectFieldNames (array): array of full field names that will be selected by the user to fill in the values of targetFieldNames
    • all select fields must be in the select table
    • the number and order of select field must match the number and order of target fields
  • visibleFieldNames (array): array of full field names that will be displayed in the select value dialog
    • all visible fields must be in the select table
    • the number and order of visible fields must match those of the select fields
  • restriction (JS object): (optional) restriction to be applied to the select value dialog content;
  • actionListener (String): (optional) name of the function that will be called by the select value dialog if the user selects any value, but before the value is saved into the opener form field
    • the event handler function is called once for every target field
    • the event handler function should define three arguments
    fieldName : target field name,
    selectedValue : value selected by the user,
    previous value : current form field value
    • the event handler function can return false to indicate that the selected values should not be copied into form fields
  • applyFilter (boolean): (optional) whether to apply the current form field values as an initial filter for the records displayed in the select value dialog; default is true ;
  • showIndex (boolean): (optional) whether to display the SmartSearch index bar; default is true;
  • width (number): (optional) width of the select value dialog;
  • height (number): (optional) height of the select value dialog;
  • selectValueType (String): (optional) dialog panel type ' grid ' or ' tree ';
  • multiple : For information, see Select Multiple Values .


Examples:

Select a value for reserve.requested_by from a list of all employees in the employee table. Display employee ID and email in the select value dialog:

View.selectValue(
'reserve_console',
'',
['reserve.requested_by'],
'em',
['em.em_id'],
['em.em_id', 'em.email']
);


Select values for reserve.requested_by and reserve.requested_for from a list of all employees in the employee table. Fill in both values using the selected em.em_id value.

View.selectValue(
'reserve_console',
'',
['reserve.requested_by', 'reserve.requested_for'],
'em',
['em.em_id', 'em.em_id'],
['em.em_id', 'em.email']
);


Select a value for reserve.requested_by from a list of employees from the Software division:

View.selectValue(
'reserve_console',
'',
['reserve.requested_by'],
'em',
['em.em_id'],
['em.em_id', 'em.email'],
"em.dv_id LIKE 'SOFT%'"
);


Select a value for reserve.requested_by . When the user selects any value, enable the Search button on the console:

View.selectValue(
'reserve_console',
'',
['reserve.requested_by'],
'em',
['em.em_id'],
['em.em_id', 'em.email'],
'',
'afterSelectRequestedBy');
...
...
function afterSelectRequestedBy(fieldName, selectedValue, previousValue) {
// enable button
$('search_btn').disabled = false;
// allow the selected value to be saved to the form
return true;
}
}

Example of custom workflow rule id that displays data records in the Select Value dialog

public void selectValueExample(Map<String, Object> parameters) {
// load the data source form the view file,
DataSource dataSource = DataSourceFactory.loadDataSourceFromFile(
"my-view.axvw", "my-data-source");

// initialize the data source;
dataSource.setContext();

// apply grid parameters to the data source
if (parameters != null) {
ReportUtility.handleParameters(dataSource, parameters);
}

// get data records from the data source
String restriction = (String) parameters.get("restriction");
List<DataRecord> records = dataSource.getRecords(restriction);

// return data set
DataSetList dataSet = new DataSetList();
dataSet.addRecords(records);
context.setResponse(dataSet);
}