Skip to main content
September 9, 2023
Question

Selectable Grid

  • September 9, 2023
  • 4 replies
  • 0 views

Hey there! 

I am working with a selectable grid,  the user is supposed to select a row and then the account number of that row should appear in the text as shown in the image. 

the thing is that i tried to used "index" with the variable "selectedEmployee- where i save the selection" but the value still does not show in the text. 

What am i doing wrong? how can i fix it? 

   a!sectionLayout(
            label: "",
            contents: {
              a!gridField(
                label: "",
                
                labelPosition: "ABOVE",
                data: local!info3,
                columns: {
                  a!gridColumn(
                    label: "Account Number",
                    value: fv!row['recordType!{e54cd4e6-9c62-49a2-82d6-965f3a86b2e7}SKJ Account.fields.{afb4d4c6-e193-4650-8165-83cfacf7b5df}accountId']

                  ),
                  a!gridColumn(
                    label: "Account Balance",
                    value: fv!row['recordType!{e54cd4e6-9c62-49a2-82d6-965f3a86b2e7}SKJ Account.fields.{a26624aa-6c8b-4ad4-b696-f52169531873}accountBalance']

                  ),
                  a!gridColumn(
                    label: "Currency",
                    value: fv!row['recordType!{e54cd4e6-9c62-49a2-82d6-965f3a86b2e7}SKJ Account.relationships.{a0795917-dbcb-4e87-8928-253944204ea6}skjCurrency.fields.{de6af13f-a763-462f-9369-8cd8bbbf1075}descAr']

                  ),
                  a!gridColumn(
                    label: "Dollar Equ",
                    value: fv!row['recordType!{e54cd4e6-9c62-49a2-82d6-965f3a86b2e7}SKJ Account.fields.{48c2c2cc-59fa-42cc-a496-c512f51c25bf}dollarEqu']

                  ),

                  a!gridColumn(
                    label: "Ledger",
                    value: fv!row['recordType!{e54cd4e6-9c62-49a2-82d6-965f3a86b2e7}SKJ Account.relationships.{2610d7fb-aa78-4df6-baf4-ddc7da46ae28}skjLedger.fields.{d9af7560-5c5f-4b4e-88d0-9ad09f40d66d}descAr']

                  )

                },
                selectable: true,

                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))
                },
                selectionRequired: true,
                validations: {}
              )
            },
                  showWhen: and(

         not (isnull    ( ri!record['recordType!{2206daff-ddbb-4759-a797-1588754c3925}SKJ Deposit Request.fields.{28dd8d8f-b6e5-4296-bd84-140d88fa784e}accountId'])),


         not(isnull(ri!record['recordType!{2206daff-ddbb-4759-a797-1588754c3925}SKJ Deposit Request.fields.{5e7d5399-0fa2-469f-a894-f34d7cd52f27}branchId']))
       )
          )
        },
        divider: "BELOW"
      ),
      a!sectionLayout(
        label: "Debit Account",
        labelIcon: "file-invoice-dollar",
        labelSize: "SMALL",
        labelColor: "STANDARD",
        contents: {
          {
            a!localVariables(
              /* This variable is used to persist the checkbox on selected items by holding the identifiers of the selected rows. */
              local!selection,
              /* This variable would be used to pass the full rows of data on the selected items out of this interface, such as to a process model. */
              local!selectedEmployees,
              local!ind:index(local!selectedEmployees,1,"null"),
              local!indexNew:index(local!ind,1,"null"),
              {
        
                a!horizontalLine(
                  weight: "THICK",
                  color: "#8e7cc3"
                ),
                {
                  a!localVariables(
                    /* This variable is used to persist the checkbox on selected items by holding the identifiers of the selected rows. */
                    local!selection,
                    /* This variable would be used to pass the full rows of data on the selected items out of this interface, such as to a process model. */
        
                    {
                      a!columnsLayout(
                        columns:{
                          a!columnLayout(
                            contents:{
                              a!columnsLayout(
                                columns: {
                                  a!columnLayout(
                                    contents: {
                                      a!textField(
                                        label: "Account Number",
                                        labelPosition: "ABOVE",
                                        value : local!ind['recordType!{e54cd4e6-9c62-49a2-82d6-965f3a86b2e7}SKJ Account.fields.{afb4d4c6-e193-4650-8165-83cfacf7b5df}accountId'],
                                        saveInto:local!ind['recordType!{e54cd4e6-9c62-49a2-82d6-965f3a86b2e7}SKJ Account.fields.{afb4d4c6-e193-4650-8165-83cfacf7b5df}accountId'],
                                        refreshAfter: "UNFOCUS",
                                        validations: {}
                                      )
                                    }
                                  ),
                                  a!columnLayout(
                                    contents: {}
                                  ),
                                  a!columnLayout(
                                    contents: {}
                                  )
                                }
                              )
                    
                            }
                          ),

4 replies

stefanhelzle0001
Brainy
September 9, 2023

It seems like a mistake in the declaration of your local variables. The grid can only save that value if the grid is inside the scope of where you declared these locals.

docs.appian.com/.../Local_Variables.html

September 9, 2023

but when i select a row and check the local variables it looks like the value is saved 

stefanhelzle0001
Brainy
September 9, 2023

Yeah ... the syntax checker in Appian has some edge cases. Please make sure to get variable scope right.