Skip to main content
evanr
October 1, 2021
Solved

Grid from Record Data: Indexing out of Grid Selection

  • October 1, 2021
  • 7 replies
  • 1 view

Hello,

I'm displaying a selectable read-only grid on an interface, and the grid is sourced from a record type (entity-backed).  Based on what row the user selects, I want to use various fields from that row elsewhere.

I.e.,

a!gridField(
...
selectable:true,
selectionValue:local!mySelection,
selectionSaveInto: {
        a!save(local!selectedRow, index(fv!selectedRows, length(fv!selectedRows), null)),
        a!save(local!mySelection, index(save!value, length(save!value), null))
      }
)

My local!selectedRow looks great.  But, when I try to reference this elsewhere, like:

local!myselectedRow.name

I get an error: "must be indexed by its corresponding record type fields or relationship".

How can I index this as if it were a CDT? (which...since it is an entity-backed record, I would think I can treat it as a CDT of that entity type).

My only workaround is to do a cast() within my saveInto, but I hope there is a cleaner way.

Best answer by evanr

I ran into this problem recently again, and figured it out - you can perform the indexing using:

local!mySelectedRow[recordType!<recordType>.<field>]

7 replies

mikes0011
Brainy
October 1, 2021

The "record type sourced" notation is a little annoying in the way it's different (and not well documented IMHO) - my first guess is that you could try the new notation like "local!myselectedRow[recordType.name]".  Beyond that I'm not sure, and will be interested to see what others chime in with.

stefanhelzle0001
Brainy
October 2, 2021
mikes0011
Brainy
October 4, 2021

I note the documentation explains how to perform a!queryRecordType calls, but then isn't very clear on how to reference the results.  And Evan's question seems to be more complicated still.