Expression evaluation error at function 'contains' [line 39]: Invalid types, can only act on data of the same type (Any Type, Text)

Hello All,
I need to read an array extracted by a datasubset just to know if it contains a particular string
Following the code

contains(
index(
local!datasubset.data,
"status",
null
)
,"TO DO")


I have this eror
Expression evaluation error at function 'contains' [line 39]: Invalid types, can only act on data of the same type (Any Type, Text)

How can I do ?

Thanks
Elia

OriginalPostID-253930

  Discussion posts and replies are publicly visible

Parents
  • +1
    Certified Lead Developer
    Be careful - contains() expects its first parameter to be an array, and in this case it's an array of the property "status" from your datasubset. Wrapping this in "tostring()" will cause the whole array to be converted into one concatenated string, in which case your contains() call will return FALSE in cases where it should return TRUE.

    I think the proper rule to use in this case would be 'touniformstring()', which converts an array into an array of strings.
Reply
  • +1
    Certified Lead Developer
    Be careful - contains() expects its first parameter to be an array, and in this case it's an array of the property "status" from your datasubset. Wrapping this in "tostring()" will cause the whole array to be converted into one concatenated string, in which case your contains() call will return FALSE in cases where it should return TRUE.

    I think the proper rule to use in this case would be 'touniformstring()', which converts an array into an array of strings.
Children