Check if type is a list

How do you check if variable is a list? Assuming that the variable is a local variable

  Discussion posts and replies are publicly visible

Parents Reply Children
  • A rule returns either list or a single CDT value. However, these rule calls integration between two services which have different data types. ServiceOne  returns a list of a CDT all the time no matter what while ServiceTwo returns a CDT.

    Downstream rules need to evaluate them differently. However, if the ServiceOne returns only one value in the list - the count is 1. For the ServiceTwo, if you check the count it is always 1.

    Thus, there is ambiguity on how to approach to process the values when there is only one row in the list.

    ServiceOne -- index(local!results, 1, "field", null) 

    OR

    ServiceTwo -- index(local!results, "field", null)

  • If you're checking to see if the the variable is a list, you can make an expression rule like this:

    ri!input would be of type Any Type

    typeof(ri!input) = typeof({ri!input})

    Alternatively, you could also cast ServiceTwo to a list each time you receive the response. That way you can keep using the same index() logic