Skip to main content
June 17, 2022
Question

Castinvalid error(Could not cast from Number (Integer) to MY CDT.

  • June 17, 2022
  • 3 replies
  • 0 views

Hello

How to convert integer value to CDT data type.
I am getting cast invalid error when I am trying to store a value in my cdt field from rule input.
I try two pattern .(plz check below of screenshot)
pattern ①:integer value of rule input


pattern ②: integer array value of rule input.


Please help me to explain why this error occur and how to resolve it .

Thanks a lot

3 replies

stefanhelzle0001
Brainy
June 17, 2022

You cannot convert a number into a data structure with multiple fields. How should Appian know where to put the value? What do you want to achieve?

stevene0005
June 21, 2022

You cannot cast a Number/Integer (a single value) to your CDT (which contains 3 mapped key-value pairs). Invalid conversion. Appian Docs has a section about Casting; can also look at Appian Functions under Quick Links (top navigation bar).

You cannot convert the integer value to a CDT, but you can map the value to a field in the CDT (like the 'id' field). Example below. When you do it, you would want to type in: type!RB_Test. It should pop up with autofill that looks closer to below. When you put the cursor inside the parenthesis at the end of it, on the bottom left of that screen, it will show you the keys for that CDT.

'type!{urn:com:appian:types:RB}RB_Test'( id: ri!integer )     =>     TEST RULE     =>     RB_Test{ id: 100, name: null, memo: null }

girlc0001Author
June 22, 2022

[mention:cba2d15574454a4dabff090890dd1409:e9ed411860ed4f2ba0265705b8793d05]

Thank u for your reply and detail of explaination.Now i understood it.
At first i tried to convert Integer value(a single value or list of number array) to my cdt.
that is a reason for cause of CastInvalid error.

Thanks for your help...