Hi Experts,
How to use Index Function to extract whole row data from a list of records based on one record field value?
We want to extract one row data from local! data where one fieldname : id has a value: 100051
Discussion posts and replies are publicly visible
To get a single item you can just use the displayvalue function.
a!localVariables( local!data: { a!map(id: 7, name: "Max"), a!map(id: 42, name: "Otto"), a!map(id: 100, name: "Joe"), }, displayvalue( 42, local!data.id, local!data, null ) )
Good to know. I always used index( array of CDT, wherecontains( ID I want to find, arrayofCDT . idField))
Unknown said:To get a single item
This is the issue with displayvalue that it only searches for the first occurrence of the given value in the list and returns corresponding replacement value, dk when they will enhance it to return multiple values.
That's why we always use a generic rule to perform such operation.
index( local!data, wherecontains(42, local!data.id), null )
Although in this case it will work nevertheless, assuming that the searched value is always unique here.