com.tibco.bds.common.exception.BDSDAInvalidDataViewException: A value specified was not of the appropriate type for the data type

com.tibco.bds.common.exception.BDSDAInvalidDataViewException: A value specified was not of the appropriate type for the data type

book

Article ID: KB0070957

calendar_today

Updated On:

Products Versions
TIBCO BPM Enterprise (formerly TIBCO ActiveMatrix BPM) 4.3.0, 4.3.1, 4.3.2

Description

In the script task, when attempting to locate a case using the 'findCaseByCriteria(String DQL)' method with a caseIdentifier containing eight or more digits, an error is encountered:

e.g. 
Parameter = 10470836;
var query = "caseIdentifier = :Parameter";
var cert = cac_com_example_casedatademo_Case1.createCriteria(query);
cert.setQueryParameter("Parameter", Parameter);
cac_com_example_casedatademo_Case1.findByCriteria(cert);

Error - 

com.tibco.bds.common.exception.BDSDAInvalidDataViewException: A value specified was not of the appropriate type for the data type [Operator=EQ,Value=1.0470836E7,Class=java.math.BigInteger,AttributePath=caseIdentifier]

Cause :

BPM Enterprise uses the Rhino JavaScript engine to execute scripts. JavaScript, including Rhino, treats all numbers as double-precision floating-point numbers. Consequently, when the Parameter is set to 10470836 initially, it is treated as a double-precision floating-point number.

However, the caseIdentifier is expected to be of type java.math.BigInteger, which is an arbitrary-precision integer type. When the floating-point number 10470836 is directly passed as a query parameter, it gets automatically converted to its scientific notation (1.0470836E7), which is a common way to represent large floating-point numbers in scientific and engineering contexts.

JavaScript can accurately represent numbers up to seven digits, as it utilizes double-precision floating-point:
e.g.
9999999 will be represented as 9999999.0 and
10000000 will be represented as 1.0E7

Issue/Introduction

Finding the case using findCaseByCriteria(String DQL) fails when the caseIndenfier has eight or more digits. The article helps resolve the error - "com.tibco.bds.common.exception.BDSDAInvalidDataViewException: A value specified was not of appropriate type for the data type"

Environment

ALL

Resolution

To avoid this conversion and to pass Parameter as a java.math.BigInteger, the toFixed() method can be used to explicitly format it as a string without any scientific notation. The toFixed() method returns a string representation of numObj that does not use exponential notation.

By applying toFixed() to Parameter, the integer 10470836 is effectively converted to a string representation of the integer. This would make it compatible with the expected java.math.BigInteger data type and this avoids the automatic conversion to its scientific notation.

The updated script from the above example will look like:
Parameter = 10470836;
var query = "caseIdentifier = :Parameter";
var cert = cac_com_example_casedatademo_Case1.createCriteria(query);
cert.setQueryParameter("Parameter", Parameter.toFixed());
cac_com_example_casedatademo_Case1.findByCriteria(cert);