Indexing in list of array

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

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    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.

Reply
  • 0
    Certified Lead Developer

    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.

Children
No Data