List with 2 items but length says it only has 1

Appian says I have a List of Text with 2 items, but when I try to get its length it says it has only 1 item.

I need to do a flatten here to achieve the right response with 2 items and its type is not even a List of List of Text.

Code for reference:

a!localVariables(
  local!test: index({ code: { "A", "B" } }, "code", null),
  length(local!test)
)

Am I doing something wrong here ? I'm really not getting it :/

For me seems Appian is interpreting the type wrong here because of its dynamic typing and even if it says the list has 2 items on the local variables, the interpreter is doing something different.

From time to time we are facing little consistence issues like those and defects are being opened by QA and they take a lot of time for us to find out what the problem really is.

This is something so core to the platform that we assume that it's working, but here and there this kind of stuff keeps hapening.

We are needing to defend ourselfs against the platform because of this kind of stuff, but doing so we create a lot of unecessary overloads for the system.

This really wears us down :/

Really hope I'm doing something wrong here

  Discussion posts and replies are publicly visible

Parents
  • I agree, this is an area where Appian can be confusing. The technical issue behind this is that you've got a dictionary, which doesn't enforce types; everything inside a dictionary is of type "Any Type". So the "code" item is a single Any Type object, which contains two things. You can verify this by typename(typeof(local!test)). So the length is technically correct--local!test is a single object--but it's not ultimately what you want. And, of course, the Local Variables section doesn't reflect this, which I agree can be frustrating.

    The best fix is to use a!map instead of a dictionary:

    local!test: index( a!map( code: {"A", "B"} ), "code", null )

    Maps preserve types, so in this case, local!test is properly a List of Text String, and the length is 2.

Reply
  • I agree, this is an area where Appian can be confusing. The technical issue behind this is that you've got a dictionary, which doesn't enforce types; everything inside a dictionary is of type "Any Type". So the "code" item is a single Any Type object, which contains two things. You can verify this by typename(typeof(local!test)). So the length is technically correct--local!test is a single object--but it's not ultimately what you want. And, of course, the Local Variables section doesn't reflect this, which I agree can be frustrating.

    The best fix is to use a!map instead of a dictionary:

    local!test: index( a!map( code: {"A", "B"} ), "code", null )

    Maps preserve types, so in this case, local!test is properly a List of Text String, and the length is 2.

Children