Only fields with scalar types can be indexed from an array.

Hello

I am facing below issue

I created local called

 local!gridDataStructure: 'type!{urn:com:appian:types}CDT'(

role:{1,2,3}

.

.

.

.

.

)

role is type of list of integer

When i try to print as  local!gridDataStructure.role it throwing an error as

a!gridLayout [line 1068]: Cannot index "role" because it is an array type (List of Number (Integer)). Only fields with scalar types can be indexed from an array.

I tried applying hard coded index([1]) still it's giving a same error.

Please suggest the solution

  Discussion posts and replies are publicly visible

Parents
  • Usually this happens if you have an array of arrays. Is it possible that local!gridDataStructure also contains an array of CDT? Here's an example: 

    a!localVariables(
      local!test: {
        'type!{urn:com:appian:types:PDL}PDL_TestNestedCDT'(
          list:{1,2,3}
        ),
        'type!{urn:com:appian:types:PDL}PDL_TestNestedCDT'(
          list: {4,5,6}
        )
      },
      index(index(local!test, 1, {}), "list")
    )

    This will work because I first index into the first item of "PDL_TestNestedCDT", then index into "list". However, it wouldn't be possible to directly enter local!test.list because that results in a list of lists.

    If you need to display or perform a calculation with this, you can also get around this by using a!forEach() like this: 

    a!localVariables(
      local!test: {
        'type!{urn:com:appian:types:PDL}PDL_TestNestedCDT'(
          list:{1,2,3}
        ),
        'type!{urn:com:appian:types:PDL}PDL_TestNestedCDT'(
          list: {4,5,6}
        )
      },
      a!forEach(
        items: local!test,
        expression: fv!item.list
      )
    )

Reply
  • Usually this happens if you have an array of arrays. Is it possible that local!gridDataStructure also contains an array of CDT? Here's an example: 

    a!localVariables(
      local!test: {
        'type!{urn:com:appian:types:PDL}PDL_TestNestedCDT'(
          list:{1,2,3}
        ),
        'type!{urn:com:appian:types:PDL}PDL_TestNestedCDT'(
          list: {4,5,6}
        )
      },
      index(index(local!test, 1, {}), "list")
    )

    This will work because I first index into the first item of "PDL_TestNestedCDT", then index into "list". However, it wouldn't be possible to directly enter local!test.list because that results in a list of lists.

    If you need to display or perform a calculation with this, you can also get around this by using a!forEach() like this: 

    a!localVariables(
      local!test: {
        'type!{urn:com:appian:types:PDL}PDL_TestNestedCDT'(
          list:{1,2,3}
        ),
        'type!{urn:com:appian:types:PDL}PDL_TestNestedCDT'(
          list: {4,5,6}
        )
      },
      a!forEach(
        items: local!test,
        expression: fv!item.list
      )
    )

Children