I'm working on an expression rule that takes two inputs: an integer value (f

I'm working on an expression rule that takes two inputs: an integer value (fieldname is key), and a CDT array (AnyType) where one of the fields I want to search on is named Key..so MyCDT.Key. The expression rule is actually more complex then this but to isolate my issue I am giving only the specifics here. Anyhow, here is the rule:

= load(
wherecontains(
ri!key,
ri!MyCDT.Key
)
)

I'm getting the following error:
"There was an error testing the rule:
Expression evaluation error at function 'wherecontains' parameter 2 [line 2]:"

I'm pretty certain this has to do with the fact that something is lost in passing something over to the expression rule--that it has no clue what this AnyType is. Perhaps I need to do an explicit cast of my AnyType into a CDT array?

OriginalPostID-140688

OriginalPostID-140688

  Discussion posts and replies are publicly visible

Parents
  • You could either set ri!key to text and then use
    whereContains(ri!key, touniformstring(ri!myCDT.key))

    or use something like the below to explicitly cast the any type array to an array of type myCDT

    with(
    local!myResolvedCDT: apply(rule!resolveCDT(_), ri!myCDT),
    local!result: whereContains(ri!key, local!myResolvedCDT.key),
    local!result
    )
    where resolveCDT is
    'type!{nameSpace}myCDT'(
    key: ri!myCDT.key,
    field2: ri!myCDT.field2
    ......
    )
Reply
  • You could either set ri!key to text and then use
    whereContains(ri!key, touniformstring(ri!myCDT.key))

    or use something like the below to explicitly cast the any type array to an array of type myCDT

    with(
    local!myResolvedCDT: apply(rule!resolveCDT(_), ri!myCDT),
    local!result: whereContains(ri!key, local!myResolvedCDT.key),
    local!result
    )
    where resolveCDT is
    'type!{nameSpace}myCDT'(
    key: ri!myCDT.key,
    field2: ri!myCDT.field2
    ......
    )
Children
No Data