Skip to main content
mollyn6512
November 21, 2022
Question

Index from a local variable querying data from the data table

  • November 21, 2022
  • 3 replies
  • 0 views

Hello everyone, 

I have a local variable that query data from data table.The data looks like below: 

local!cases: {

(clientId: 234,group: 55),

(clientId: 600, group: 66),

(clientId:234, group: 77),

(clientId: 600, group: 88),

(clientId: 234, group: 99)

}

I want to get the group name of only client number 600. Below is my code: 

index(local!cases.group,wherecontains(600,tointeger(local!cases.clientId)),null),

And got this error:  Invalid index: Cannot index property 'group' of type Text into type List of Number (Integer)

Any one got an idea what the reason is? Thanks a lot!

    3 replies

    stefanhelzle0001
    November 21, 2022

    Are you sure that your data really looks like this?

    This: (clientId: 234,group: 55),

    is not an Appian dictionary. It should use curly brackets:  {clientId: 234,group: 55},

    Can you share a better working code example?

    mollyn6512
    November 21, 2022

    Sorry I was trying to create a similar data as mine was a list queried from DB.

    The right format should be as you said:

    local!cases: {

    {clientId: 234,group: 55},

    {clientId: 600, group: 66},

    {clientId:234, group: 77},

    {clientId: 600, group: 88},

    {clientId: 234, group: 99}

    }

    I’ve checked and group is actually a list of number(integer), not text as stated

    stefanhelzle0001
    November 21, 2022

    This works perfectly fine for me.

    a!localVariables(
      local!cases: {
    
        {clientId: 234,group: 55},
    
        {clientId: 600, group: 66},
    
        {clientId: 234, group: 77},
    
        {clientId: 600, group: 88},
    
        {clientId: 234, group: 99}
    
      },
      index(local!cases.group,wherecontains(600,tointeger(local!cases.clientId)),null),
    )