How do you check if variable is a list? Assuming that the variable is a local variable
Discussion posts and replies are publicly visible
Can you add more details about your use case and what you're trying to do? A variable is just a reference to a value. You can use the contains() or wherecontains() functions to help find values within a list.
Hey Danny, I am trying to check if a certain variable is a list or not.
For example:
What are you hoping to do with this? I assume Danny was asking for some more information about your overall use case, as we can provide more detailed guidance that way.
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
My lists check is:
runtimetypeof(ri!value) = runtimetypeof(cast(runtimetypeof({index(ri!value, 1, null)}), ri!value))
This compares the input type to a list of the same type as the first item in the input.
Made a small modification to your code - it was giving me type 157 when I was passing it a single integer - also handles nested dictionary values.
runtimetypeof( cast( runtimetypeof({index(a!flatten(ri!value), 1, null)}), a!flatten(ri!value) ) )