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


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

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer
    11 months ago

    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?

  • 0
    Certified Associate Developer
    11 months ago

    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 }

  • 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...