Selectable Editable Grid

I have(had) an issue with a Selectable Editable Grid and I don't know if this is a bug or not.

BUSINESS USE CASE

I actually have two grids.  The Use Case here is to have the user assign a speaker to a parish for a parish event.

One grid shows unassigned approved speakers and the other shows parishes that do not have a speaker.  There are two local variables that are loaded with this data; speakerEvents and parishEvents.  The user selects the Speaker, then selects the Parish before submitting the data.

Here is the JSON for one of the grids.

                 a!gridLayout(
                    label: "Unassigned Approved Speakers",
                    labelPosition: "ABOVE",
                    emptyGridMessage: "There are no Unassigned Approved Speakers for this Event.",
                    headerCells: {
                      a!gridLayoutHeaderCell(label: "Speaker"),
                      a!gridLayoutHeaderCell(label: "Type"),
                      a!gridLayoutHeaderCell(label: "Language"),
                      a!gridLayoutHeaderCell(label: "Accommodations")
                    },
                    columnConfigs: {
                      a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
                      a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
                      a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
                      a!gridLayoutColumnConfig(width: "NARROW")
                    },
                    rows: {
                      a!forEach(
                        items: local!speakerEvents,
                        expression: a!gridRowLayout(
                          id: fv!index,
                          contents: {
                            a!textField(
                              label: "Speaker",
                              labelPosition: "COLLAPSED",
                              value: rule!PMSO_GetSpeakerFullNameTextBySpeakerId(
                                fv!item['recordType!PMSO Speaker Event.fields.speakerId']
                              ),
                              readOnly: true
                            ),
                            a!textField(
                              label: "Type",
                              labelPosition: "COLLAPSED",
                              value: rule!PMSO_GetSpeakerTypeTextBySpeakerId(
                                fv!item['recordType!PMSO Speaker Event.fields.speakerId']
                              ),
                              readOnly: true
                            ),
                            a!textField(
                              label: "Languages",
                              labelPosition: "COLLAPSED",
                              value: rule!PMSO_getSpkrLanguageNamesForSpeakerId(
                                fv!item['recordType!PMSO Speaker Event.fields.speakerId']
                              ),
                              readOnly: true
                            ),
                            a!textField(
                              label: "Accommodations",
                              labelPosition: "COLLAPSED",
                              value: if(
                                rule!PMSO_getSpkrAccommodationsForSpeakerId(
                                  fv!item['recordType!PMSO Speaker Event.fields.speakerId']
                                ),
                                "Yes",
                                "No"
                              ),
                              readOnly: true
                            )
                          }
                        )
                      )
                    },
                    selectionValue: local!selectedSpeakerEventIndex,
                    selectionSaveInto: local!selectedSpeakerEventIndex,
                    selectable: true,
                    selectionStyle: "ROW_HIGHLIGHT",
                    selectionRequired: true,
                    shadeAlternateRows: true
                  )

It seems that I can only use fv!index as the id in the gridRowLayout function.  Is this a bug?!?

If I use fv!identifier, all of the records in the grid are "selected" when the grid is displayed even though they are not selected.

I tried to use the fv!item.speakerEventId, it throws an HTML 500 error.  This is the tomcat-stdOut.log

2025-04-21 07:00:44,225 [RecordSyncScheduler_Worker-2] ERROR com.appiancorp.record.data.recordloaders.ads.RecordTypeAdsLoadService - Error creating join index for relationship with uuid: 
com.appian.data.client.AdsUserInputException: APNX-3-1000-06D: Invalid parameter specified to the createJoinIndex function. Attrs must reference valid attributes. Invalid attr ref(s): []

I got around the problem by using the index as the id and adding a save into the saveinto function of the submit button.

a!save(ri!selectedSpeakerEvent, index(local!speakerEvents, local!selectedSpeakerEventIndex))

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    I suspect you need to understand a bit more about what you're doing with your row selection and how it works.  It depends on the finer details of what the value (and data type) of local!speakerEvents is, which you haven't specified - but either way, you need to know what a!forEach() actually does in order to allow use of "fv!identifier" --

    This means that fv!identifier will only pick up the value of the primary key ID when it's passed a set of dataSubset data (specifically); other times it will behave in ways I hesitate to even guess at without checking myself, including setting the identifier value to null, setting it to a static value, or not even resolving a value for it. (my initial try suggests the 'all nulls' hypothesis might be the most correct, see below)

    So to help further, we'll need to know what value you're working with there, and why it's not sufficient for you to set each row's "id" parameter to that row's primary key ID instead of fv!index (which will always just be its relative position within the a!forEach() iteration).

    Also -- as an aside, and at the risk of being a bit pedantic:

    Here is the JSON for one of the grids.

    I need to stop you right there - JSON is the name of a very specific format, one in which some set of ordered data (dictionary, array, or combo of both) has been flattened into a single text string, with predefined parsing parameters, to take the guesswork out of unpacking it on the other end.  See the output of when you pass something through the "a!toJson()" function for a working example of what JSON will look like.  What you've shared here is simply SAIL code (which is just fine), but it has nothing to do with JSON.

  • The local variable, speakerEvents is loaded via an expression rule, PMSO_GetUnassignedApprovedSpeakerEventsbyEventID().  This expression rule returns a list of the record type, PMSO Speaker Event and it includes the id, speakerEventId.

    I hope this answers you question.

    Thank you for the clarification on JSON and SAIL.  It is OK to be pedantic with us newbies.

Reply Children