Skip to main content
March 22, 2021
Question

condition to check if type is a CDT

  • March 22, 2021
  • 15 replies
  • 0 views

Hello community,

I wonder if it is possible to check with in a if condition if a passed value of any type is a CDT.
I want to make a generic expression rule to convert a body from JSON to CDT with two rule inputs.
1 body of type text.
2 any type, but only CDT's so no integer, string etc.

So I want the to JSON function only to execute when the ruleinput is a CDT, if not I want to return a custom error message text string.
Are the CDT in a specific reserved numeric range so I can use that, or is there another approach?

Kind Regard,

Erik

15 replies

stefanhelzle0001
Brainy
March 22, 2021

I think there are two types you need to consider. Dictionary and Map. The types are

'type!{www.appian.com/.../2009}Dictionary'

'type!{http://www.appian.com/ae/types/2009}Map'

You can use them to compare to "runtimetypeof(ri!YOUR_RULE_INUT)"

erikb0001Author
March 22, 2021

Thank you Stefan,

Maybe it's my environment, or I misunderstood your answer.

I am not able to find the types you mention to compare.
It I type: 'type!{www.appian.com/.../2009}Dictionary' or 'type!{http://www.appian.com/ae/types/2009}Map' in the if expression.
It seems that I can only access CDT's in the system.

Kind Regards,

Erik

stefanhelzle0001
Brainy
March 23, 2021

These are not auto-completed. Your code would look like

if(
  or(
    runtimetypeof(ri!YOUR_RULE_INPUT) = 'type!{http://www.appian.com/ae/types/2009}Dictionary',
    runtimetypeof(ri!YOUR_RULE_INPUT) = 'type!{http://www.appian.com/ae/types/2009}Map'
  ),
  __THIS__,
  __THAT__
)