You are currently reviewing an older revision of this page.

DRAFT KB-XXXX The given datatype id 97 is not a primitive type error received when using the index() function on a List of Dictionaries

Symptoms

The application server log returns the following error when trying to retrieve multiple values from an array using the index() function:

java.lang.IllegalArgumentException: The given datatype id 97 is not a primitive type.

Cause

When using the index() function to extract data from a variable or rule that uses a type of List of Dictionaries, then the value that is indexed out is one that is essentially wrapped in a type 97.

Action

To prevent this error from happening, cast the value to an integer or text using additional functions like tointeger() or tostring().  For example:

identifiers: tostring(index(local!listOfDictionaries, local!valueToIndexOn, {}))

identifiers: tointeger(index(local!listOfDictionaries, local!valueToIndexOn, {}))

Workaround

An additional error may appear if the size of the lists or lengths that are indexed out are larger or longer than the target rule or variable that is meant to store them.  The following error was seen in a record when formatting an identifiers: section in the a!dataSubset() function.

ERROR com.appiancorp.expression.plugin.RecordsSailFunctions - There was a problem retrieving the record type with urlstub [jQpe8Q] java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
at java.util.ArrayList.rangeCheck(ArrayList.java:653)
at java.util.ArrayList.get(ArrayList.java:429)
at com.appiancorp.convert.record.ListViewToUserDtoRecordItemConverterImpl.convert(ListViewToUserDtoRecordItemConverterImpl.java:74)
at com.appiancorp.expression.plugin.RecordsSailFunctions.getRecordItemContainer(RecordsSailFunctions.java:428)
at com.appiancorp.expression.plugin.RecordsSailFunctions.getrecordlistmodel_appian_internal(RecordsSailFunctions.java:200)
at sun.reflect.GeneratedMethodAccessor3208.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)

This can be worked around by using an apply() function to cast each item indexed out to a String or integer.  Depending on the use case, however, apply() may be unnecessary.  Please refer to the tostring() and tointeger() documentation for more information.  The split() function may also be utilized, but could be more unpredictable if the data just so happened to include the character one chooses to split on.

Some examples that can be tested:

identifiers: apply(tostring(index(local!listOfDictionaries, local!valueToIndexOn, {})))

identifiers: apply(touniformstring(index(local!listOfDictionaries, local!valueToIndexOn, {})))

identifiers: tointeger(index(local!listOfDictionaries, local!valueToIndexOn, {}))

identifiers: apply(tointeger(index(local!listOfDictionaries, local!valueToIndexOn, {})))

identifiers: split(tostring(index(local!listOfDictionaries, local!valueToIndexOn, {})),";")
This would essentially be a list of multiple items that were indexed out instead of seeing a comma or semi-colon separated list as one single String.

Affected Versions

This article applies to all versions of Appian.

Last Reviewed: August 2018