Issue with grid selection when storing objects

Certified Senior Developer

Hi,

I'm trying this tutorial... 

docs.appian.com/.../Grid_Tutorial.html

I'm interesting about the two code lines that enables to store the Object selected items :

selectionSaveInto {

  a!save(local!selectedVehicles, append(local!selectedVehicles, fv!selectedRows)),
  a!save(local!selectedVehicles, difference(local!selectedVehicles, fv!deselectedRows))

  All works fine, but could you explain me why when I'm try to set  local!selectedVehicles into a Rule Input. I obtain this error below please ?

I've just addied 2 lines of code :

a!localVariables (

   local!selectedVehicles : ri!selectedVehicles, /* that is the same type used for the grid data, CDT type with array values */

  ...

selectionSaveInto {

  a!save(...),
  a!save(...),

  a!save(ri!selectedVehicles, local!selectedVehicles)

  Discussion posts and replies are publicly visible

  • 0
    Certified Senior Developer
    in reply to Shikha

    Thank you Shikha, but I still have this error.

    Finally, I've gave up (as a colleague just confirmed me, that he has exactly the same error few months ago)...

    I've decided to deal with the selectedIds selection ony (array of identifiers)... and then, all I need to do works like a charm now :-)

    I will wait for the next Appian versions and will re-test in the future (as I have a good workaround)...

  • 0
    A Score Level 1
    in reply to cedric01

    I tried the same code , except using one of the CDT's  that I have . It works fine for me . I am able to select/deselect the rows. 

  • 0
    Certified Senior Developer
    in reply to Shikha

    may I see the whole code please (the saveinto part) ?

  • 0
    A Score Level 1
    in reply to cedric01

    a!localVariables(
      local!selection,
      local!selectedVehicles: ri!selectedVehicles,
      /* cast(
        'type!{urn:com:appian:types:cjt2}CJT2_Vehicles', ri!selectedVehicles),
      */
      a!sectionLayout(
        contents: {
          a!columnsLayout(
            columns: {
              a!columnLayout(
                contents: {
                  a!cardLayout(
                    contents: {
                      a!gridField(
                        label: "Read-only Grid",
                        labelPosition: "ABOVE",
                        data: ri!projectDetails,
                        columns: {
                          a!gridColumn(
                            label: "Name",
                            value: fv!row.name
                          ),
                          a!gridColumn(
                            label: "Manager",
                            value: fv!row.manager
                          ),
                          
                        },
                        selectable: true,
                        selectionStyle: "CHECKBOX",
                        selectionValue: local!selection,
                        selectionSaveInto: {
                          local!selection,
                          a!save(
                            local!selectedVehicles,
                            append(
                              local!selectedVehicles,
                              fv!selectedRows
                            )
                          ),
                          a!save(
                            local!selectedVehicles,
                            difference(
                              /*cast(typeof('type!{urn:com:appian:types:AMT}projectDetails?list'),local!selectedVehicles),*/
                             local!selectedVehicles, fv!deselectedRows
                            )
                          ),
                          a!save(
                          ri!test,
                            local!selectedVehicles
                          ),
                          
                        },
                        validations: {}
                      )
                    },
                    height: "AUTO",
                    style: "NONE",
                    marginBelow: "STANDARD"
                  ),
                  
                }
              ),
              a!columnLayout(
                contents: {}
              )
            }
          ),
          a!paragraphField(
            label:"local!selectedVehicle",
            value: local!selectedVehicles
          )
        },
        showWhen: true
      )
    )

    I created Ri test of same table type (Array type). Giving some dummy values to Ri!projectDetails. 

  • 0
    Certified Senior Developer
    in reply to Shikha

    Yes, it works because your ri!test can not be used from a parent interface as an input.

    (your ri!test shows the current Objects selection only but it can not be set)

    With this code if I set the ri!test to null from my parent interface, it does not apply any modification in the selected objects of the grid. It just set the ri!test in the parent interface.

  • 0
    Certified Senior Developer
    in reply to cedric01

    Can somebody explain me why I can not use a rule input for the grid mecanism selection (to save objects), without having the "Invalid types" error above please?

    (The Shikha example is a very simple example to test this error)
     

    a!localVariables(
      local!selection,
      a!sectionLayout(
        contents: {
          a!columnsLayout(
            columns: {
              a!columnLayout(
                contents: {
                  a!cardLayout(
                    contents: {
                      a!gridField(
                        label: "Read-only Grid",
                        labelPosition: "ABOVE",
                        data: ri!projectDetails,
                        columns: {
                          a!gridColumn(
                            label: "Name",
                            value: fv!row.name
                          ),
                          a!gridColumn(
                            label: "Manager",
                            value: fv!row.manager
                          ),
                          
                        },
                        selectable: true,
                        selectionStyle: "CHECKBOX",
                        selectionValue: local!selection,
                        selectionSaveInto: {
                          local!selection,
                          a!save(
                            ri!selectedVehicles,
                            append(
                              ri!selectedVehicles,
                              fv!selectedRows
                            )
                          ),
                          a!save(
                            ri!selectedVehicles,
                            difference(
                             ri!selectedVehicles, fv!deselectedRows
                            )
                          ),
                        },
                        validations: {}
                      )
                    },
                    height: "AUTO",
                    style: "NONE",
                    marginBelow: "STANDARD"
                  ),
                  
                }
              ),
              a!columnLayout(
                contents: {}
              )
            }
          ),
          a!paragraphField(
            label:"ri!selectedVehicle",
            value: ri!selectedVehicles
          )
        },
        showWhen: true
      )
    )

  • 0
    Certified Senior Developer
    in reply to cedric01

    Thank you everybody for your help.
    It works fine now, the only thing missing was to add "?list" why doing the cast (Thanks Peter)