Skip to main content

"Unable To Cast Object Of Type..." Error Generated When Looping Through Complex Variable Mapped To Table


Question / Problem: 

A KTA (TotalAgility) Business Rule that uses a dynamic complex variable that is mapped to a table field fails with the following error when looping through the complex variable.

"Failed to execute business rule: "XXXXX". The executor returned: "Unable to cast object of type 'Agility.Sdk.Model.Variables.ComplexVarColumnMappingCollection' to type 'System.IConvertible'."

Answer / Solution: 

This error can occur if the Loop activity column mappings don't match all the all of the columns used in the table. Also, caution must be taken to use variables that match the types of the output columns to the table column types in order to prevent the error from occurring. The attached screenshot shows how all the table columns are matched to variables of the same type in the loop activity

Applies to:  

Product Version