Skip to main content
Inspiring
May 13, 2021
Question

Indexing in list of array

  • May 13, 2021
  • 2 replies
  • 0 views

Hi Experts,

I have a local variable which store list of array, I need to get the col2 value where col1 is "RF",

Kindly help with the expression as when i tried below expression but its not returning the correct value.

localVariable(

local!a: {{col1: "TX", col2: "Gaurav Singh"}, {col1: "Civil", col2: "Gaurav Singh"}, {col1: "RF", col2: "Gaurav Singh"}},

local!RF:  index(

index(local!rows,"col2",{}),
wherecontains( 

tostring( index( local!rows, "col1", {}  )  ),

 "RF"

),
{}
)
))

Kindly help

2 replies

stefanhelzle0001
Brainy
May 13, 2021

a!localVariables(
  local!a: {
    {col1: "TX", col2: "Gaurav Singh"},
    {col1: "Civil", col2: "Gaurav Singh"},
    {col1: "RF", col2: "Gaurav Singh"}
  },
  /* Get value from local!a at the same index of the value in local!a.col1 */
  displayvalue(
    "RF",
    local!a.col1,
    local!a,
    null
  )
)

davel001150
Inspiring
May 13, 2021

index(

/*I don't remember if it crashes with keywords used, some Appian functions*/

[array:]local!.a.col2

[index:]wherecontains("RF", local!a.col1)

)

Index the value you want from THIS location where you find "RF" in THAT location.

displayvalue works done correctly, but I think this is the more readable, more widely used general case.  The problem I think you're having is nesting all the index() functions rather than using the dot notation, which is often much more manageable.