Grid from Record Data: Indexing out of Grid Selection

Certified Lead Developer

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.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    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.

  • 0
    Certified Lead Developer
    in reply to Mike Schmitt

    I agree, Mike, the documentation is very unclear.  Unfortunately, your suggestion resulted in the same error as I encountered previously.  I did see in the documentation (that Stefan's answer referenced), that Appian says that you can cast record type data to a CDT.  So, I think I'm going to stick with that approach for now.  I'm interested to hear from others, as this seems unnecessary as the record type is defined from the very entity that I'm casting to.

  • 0
    Appian Employee
    in reply to Evan Rust

    Evan can you post your expression that shows an error using the new record type referencing? You can use square brackets like Mike suggested or you can also use the regular index() or property() function with a record field to return the same results.

  • 0
    Certified Lead Developer
    in reply to Peter Lewis

    Hi Peter, sample expression and screenshot below - was able to get past the previous error (must be indexed by corresponding fields...) by simplifying this a little.  Results from 3 things:

    1) Index(): doesn't pink error, but doesn't show anything

    2) Property(): pink error below

    3) Dot notation (not shown): Pink error saying you have to use index notation or record type

    a!localvariables(
      local!selectedRow,
      local!mySelection,
      local!pagingInfo:a!pagingInfo(1,10),
      {
        a!gridField(
      data:'recordType!{58c03cbc-9019-4e9b-ae8b-9ad9aa51b64a}Office',
      pagingSaveInto: local!pagingInfo,
      columns:{
        a!gridColumn(
          label:"Office",
          value:fv!row['recordType!{58c03cbc-9019-4e9b-ae8b-9ad9aa51b64a}Office.fields.{ansofficename}ansofficename']
        )
      },
      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))
      }
    ),
    a!textField(
      label:"Index",
      value:index(local!selectedRow,"ansofficename",null)
    ),
    a!textField(
      label:"Property",
      value:property(local!selectedRow,"ansofficename")
    )
    }
    )

  • +1
    Certified Lead Developer
    in reply to Evan Rust

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

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

Reply Children
No Data