Skip to main content
evanr
April 15, 2022
Solved

Record Type Paging Grid: Pre-Populating Selection

  • April 15, 2022
  • 5 replies
  • 3 views

I am creating a paging grid with selection that is based on a recordType! in my environment.

My interface is set up to follow the paradigm in https://docs.appian.com/suite/help/22.1/grid-with-selection-pattern.html#[line-1-54]-define-local-variables-and-grid-data but with the "data" parameter in the gridField obtained via recordType.

Code below:

a!localVariables(
local!selection:index(ri!selectedStuff,"id",{}),
local!selectedRows, /*this is what i need to populate*/
..
a!gridField(
data:recordType!Foo,
selectable:true,
selectionValue:local!selection,
selectionSaveInto:{
    local!selection,
    a!save(local!selectedRows,append(local!selectedRows,fv!selectedRows)),
    a!save(local!selectedRows,difference(local!selectedRows,fv!deselectedRows)),
    a!save(ri!selectedStuff,local!selectedRows)
    }
)
)

In my use case, I want to be able to pre-populate my local!selectedRows so that the grid can be pre-selected coming into the screen.

This is an entity-backed record, and passing a CDT array (of that entity) makes the page error on additional selection (why...it is an entity backed record and I am using the same entity)

I have also tried calling a queryrecordtype() to set local!selectedRows, but this also does not let me select/deselect.

How can I pre-populate the local!selectedRows with the record data I want to be selected?

Best answer by mikes0011

fv!selectedRows is difficult to use, and "recordType!" style data is super difficult to use, and you're hitting an intersection between the two.  Good luck, I guess.

passing a CDT array (of that entity) makes the page error

This is because CDT data and "recordType!" data is not cross-compatible.  Not only that but there's no direct way to cross-cast it, and (as mentioned already) it's super convoluted to do *anything* with.

My suggestions would be to pick at least one of: a) make your grid QueryEntity based; and/or 2) make your GridSelections PKID based instead of "whole row of data" based.

5 replies

stefanhelzle0001
Brainy
April 15, 2022

You will need to pass the primary key ids of the pre-selected items.

evanr
evanrAuthor
April 15, 2022

For the local!selectedRows?  This is the local variable that according to the recipe represents the *full rows* of data.  I am able to pass the PKs fine in the local!selection variable, but the issue is I can't pass existing full rows from the record in local!selectedRows.

stefanhelzle0001
Brainy
April 15, 2022

Sure, but the grid works with the value passed to the selectionValue parameter.

https://docs.appian.com/suite/help/22.1/Paging_Grid_Component.html#parameters

So, you might have to handle these separately.

selectionValue: local!selection,
selectionSaveInto: {
  local!selection,
  /* This save adds the full rows of data for items selected in the most recent user interaction to local!selectedEmployees. */
  a!save(local!selectedEmployees, append(local!selectedEmployees, fv!selectedRows)),
  /* This save removes the full rows of data for items deselected in the most recent user interaction to local!selectedEmployees. */
  a!save(local!selectedEmployees, difference(local!selectedEmployees, fv!deselectedRows))
}

mikes0011
mikes0011Answer
Brainy
April 15, 2022

fv!selectedRows is difficult to use, and "recordType!" style data is super difficult to use, and you're hitting an intersection between the two.  Good luck, I guess.

passing a CDT array (of that entity) makes the page error

This is because CDT data and "recordType!" data is not cross-compatible.  Not only that but there's no direct way to cross-cast it, and (as mentioned already) it's super convoluted to do *anything* with.

My suggestions would be to pick at least one of: a) make your grid QueryEntity based; and/or 2) make your GridSelections PKID based instead of "whole row of data" based.

The Expression Guru
evanr
evanrAuthor
April 15, 2022

I guess I'm going with Option 2.  It's great that you can use the native features of the record grid here (search etc) but I really wish there was compatibility between record types + CDTs of that same entity.  It would be nice to output the whole row instead of just the ID in case I need to access other fields in the row!  Thanks both.