cognos.Prompt.Control.getValues
method
Returns the current value for the control.
This method always returns an array, even if there is only one value selected.
The following is an example for a text box prompt (single):
[ {use: "Smith", display: "Smith"} ]
The following is an example for a select prompt (multiple):
[ {use: "CAN", display: "Canada"}, {use: "JPN", display: "Japan"} ]
The following are examples of range prompts:
A range is an array of two elements, with the mandatory names
start
andend
. The value of each element is a regular array as in earlier examples. When the range values are equal, this method returns a normal value instead of a range:[ {use: useValue, display:displayValue} ]
When the range values are different, this method returns a range:
[ start:{use: useValue, display:displayValue}, end:{use: useValue, display:displayValue} ]
Syntax
{cognos.Value[]} getValues(boolean v_allOptions)
Parameters
- {Boolean} v_allOptions
This optional parameter is applicable only to value prompts. The parameter specifies whether to retrieve all values or only selected values.
If the parameter is true, then all options are returned. If the parameter is false or missing, then only the selected options are returned.
The default value of this parameter is
false
.
Returns
- {cognos.Value[]}
- An array of values for the control.
Example
This example demonstrates how to adjust your code based on whether the result is a single value or a range.
function isRangeOutOfLimits(datePrompt, rangeLimit) {
var result = false;
var v = datePrompt.getValues();
var rangeValue = v[0];
var rangeDaysDiff = 0;
if (rangeValue.start) {
rangeDaysDiff = 0;
var startDate = rangeValue.start.use;
var endDate = rangeValue.end.use;
rangeDaysDiff = dateUtils.substractDate(endDate,startDate);
}
if (rangeDaysDiff > 0 && rangeDaysDiff <= rangeLimit) {
result = true;
}
return result;
}
This example demonstrates the use of the parameter v_allOptions
.
var allValues = valueControl.getValues(true);
var selectedValues = valueControl.getValues();