ThanXs.
=====================================================================
Here is the full code, boxed in, //+++++++++++, the errornous section:
=====================================================================
// Get alle the variables form the Query
// MANAGREP is the Table / Query
var filterName = MANAGREP.getDataSource().getVariables();
console.log("++filterName:");
console.log( filterName);
//---------------------------------------------------------------------------------------------------------
// LOOP over all Input Parameter
for ( var j=0; j < filterName.length; j++){
console.log("++filterName[j].id:");
console.log( filterName[j].id);
var filterValues = MANAGREP.getDataSource().getVariableValues(filterName[j].id)[0];
console.log("++filterValues:");
console.log(filterValues);
//---------------------------------------------------------------------------------------------------------
//Differentiate type of Input Parameter ( in ABABP: LT_RANGE) to treat values accordingly
console.log("++filterValues.type:");
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Any operation on filterValues.type breaks with this error, if the parameter is empty, what means not set in the
// query:
// "
// Cannot read properties of undefined (reading 'type')
// TypeError: Cannot read properties of undefined (reading 'type')
// at Proxy.eval (MANAGREP.onResultChanged.js:12:34)
//
// ----> How to handle an undefined input parameter ? <----------
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
console.log(filterValues.type);
switch(filterValues.type){
case VariableValueType.Single:
console.log("++VariableValueType.Single:");
console.log(VariableValueType.Single);
// Get a single value from the input parameter
var singlefilterValue = cast(Type.SingleVariableValue, filterValues );
console.log(" singlefilterValuefilterValues:");
console.log( singlefilterValue.value);
// Add some logic on the single values of the single inut parameter here:
break;
case VariableValueType.Multiple:
console.log("++VariableValueType.Multiple:");
console.log(VariableValueType.Multiple);
var multiFilterValues = cast(Type.MultipleVariableValue, filterValues);
console.log("multiFilterValues filterValues:");
console.log( multiFilterValues.values);
//---------------------------------------------------
// Loop over the values of the multiple value input parameter
for ( var i = 0; i < multiFilterValues.values.length; i++){
console.log("multiFilterValues.values[i] filterValues:");
console.log( multiFilterValues.values[i]);
// Add some logic on the multiple values of the parameterhere:
}
//---------------------------------------------------
// Loop END over the values of the parameter
break;
case VariableValueType.Range:
console.log("++VariableValueType.Range:");
console.log(VariableValueType.Range);
// Get the value of the ranges, how ?
// Add some logic on the range values of the range input parameter here:
break;
default:
console.log("++DEFAULT");
break;
//---------------------------------------------------------------------------------------------------------
//Differentiate type of Input Parameter ( in ABABP: LT_RANGE)
}
//---------------------------------------------------------------------------------------------------------
// LOOP over Input Parameter
}
console.log("FINISHED");
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.