How to deal with the slow Appian grid selection validation?

Certified Senior Developer

Hi,

I have a grid based on a RecordType, and I have coded a multi-selection mecanism inside the selectionSaveInto portion code.

When I select a line, some tests are made, but Appian takes 2 seconds to accept the selection (even if I do nothing, just click on a row).

Then I can select or deselect another line.... etc...

All works fine as, I let Appian finishing the work (progression bar is displayed at the top of the screen).

The problem goes when I click quickly on many lines: this creates some bugs.

How may I rid of this issue?  is there any way to toggle enable/disable selection after having selected a row (while Appian is working)?

or is there any way to deactivate the mouse cursor during the Appian progression bar (as we could do with any other language like Java)?

Regards 

  Discussion posts and replies are publicly visible

Parents
  • Can you paste the SAIL code you have? There is an easy way in SAIL to only allow single row selection. Some reasons why the section might be slow:

    1. Your record type is referencing a database view or large table

    2. Your grid is querying extra columns from the database

  • 0
    Certified Senior Developer
    in reply to Danny Verb

    Thank you Danny but I do not need to allow single row selection.
    I have to deal with muli-selection, but each time I select row, I have to wait 2 seconds.

  • 0
    Certified Lead Developer
    in reply to cedric01

    Without posting a sample of your SAIL code like Danny mentioned, we can't really help you without just guessing.

  • 0
    Certified Senior Developer
    in reply to Mike Schmitt

    Yes, you're right, here is my sample code:
    In my example, you can select some lines while total value of rows is less or equal to 50.

    So, if you select the "make4" row, you can not select another row (unless you unselect this row).
    But, if you click very quickly and successively on these 3 rows : "make4", "make3", "make2", you will obtain the selection like the picture below : "make3" and "make4" rows are wrongly selected and the total is 70, so it should not be possible.

    In reference of what Danny said, you can easier testing this using a database view or large table, with a lot more grid columns.




    a!localVariables(
      local!saveSelectedVehicles: null,
      local!selection: ri!selectedVehicleIds,
      local!valMaxAuto: 50, 
    
      a!sectionLayout(
        contents: {
          a!columnsLayout(
            columns: {
              a!columnLayout(
                contents: {
                  a!cardLayout(
                    contents: {
                      a!gridField(
                        label: "Read-only Grid",
                        labelPosition: "ABOVE",
                        data: ri!vehicles,
                        columns: {
                          a!gridColumn(
                            label: "Make",
                            value: fv!row.make
                          ),
                          a!gridColumn(
                            label: "Model",
                            value: fv!row.model
                          ),
                          a!gridColumn(
                            label: "Value",
                            value: fv!row.value
                          ),
                        },
                        selectable: true,
                        selectionStyle: "ROW_HIGHLIGHT",
                        selectionValue: local!selection,
                        selectionSaveInto: {
                          local!selection,
                          a!save(
                            ri!selectedVehicles, append(
                              ri!selectedVehicles, cast(
                                'type!{urn:com:appian:types:cjt2}CJT2_Vehicles?list',
                                fv!selectedRows
                              )
                            )
                          ),
                          a!save(
                            ri!selectedVehicles, 
                            difference(
                              ri!selectedVehicles, 
                              cast(
                                'type!{urn:com:appian:types:cjt2}CJT2_Vehicles?list',
                                fv!deselectedRows
                              )
                            )
                          ),
    
                          /* Manage selection acceptance */
                          a!localVariables(
                            local!maxValueAccepted: if (not(isnull(ri!selectedVehicles)),
                            sum(
                              a!forEach(
                                items: ri!selectedVehicles,
                                expression: fv!item.value
                              )
                            ),
                            0
                            ),
    
                            if (local!maxValueAccepted > local!valMaxAuto,
                            {
                              a!save(local!selection, remove(local!selection, length(local!selection))), 
                              a!save(ri!selectedVehicles, remove(ri!selectedVehicles, length(ri!selectedVehicles))),
                            },
                            null
                            )
                          ),
    
                          a!save(ri!selectedVehicleIds, local!selection)
    
                        },
                        validations: {}
                      )
                    },
                    height: "AUTO",
                    style: "NONE",
                    marginBelow: "STANDARD"
                  ),
    
                }
              ),
              a!columnLayout(
                contents: {}
              )
            }
          ),
          a!paragraphField(
            label:"ri!selectedVehicle",
            value: ri!selectedVehicles
          )
        },
        showWhen: true
      )
    )
    

  • 0
    Certified Lead Developer
    in reply to cedric01

    One potential issue here is that in your grid selection saveInto, you're doing maybe 5 or 6 consecutive operations for every single click, when you could probably accomplish the same thing in 1 or 2 operations.

  • 0
    Certified Lead Developer
    in reply to cedric01

    See my dramatically simplified example for some other options.  Instead of doing 6 consecutive saves in your SaveInto, we simply save the row ID of the selected vehicle, then use some evaluation chaining in the local variables to resolve things like selected vehicle CDT list as well as calculated selected value sums.  I'm not exactly clear on how you want to restrict row selection precisely, so I've given you 2 different options within the "disableRowSelectionWhen" parameter - basically one which will limit any new selections once the max has been exceeded, and a secondary measure which will prevent any item from being selected if it would cause the total value to exceed your limit.

    a!localVariables(
      local!vehicles: {
        {
          id: 1,
          make: "Ford",
          model: "Taurus",
          value: "$200"
        },
        {
          id: 2,
          make: "Volvo",
          model: "760 TI",
          value: "$1500"
        },
        {
          id: 3,
          make: "Chevy",
          model: "Impala",
          value: "$11,000"
        }
      },
      
      local!selection: {},
      
      local!selectedVehicles: if(
        rule!PIRS_RULE_General_isListEmpty(local!selection),
        {},
        index(
          local!vehicles,
          local!selection
        )
      ),
      
      local!valMaxAuto: 5000,
      local!totalValueSelected: if(
        not(rule!PIRS_RULE_General_isListEmpty(local!selectedVehicles)),
        sum(
          a!forEach(
            items: local!selectedVehicles,
            expression: tointeger(fv!item.value)
          )
        ),
        0
      ),
      local!maxValueReached: local!totalValueSelected > local!valMaxAuto,
      
      
      a!sectionLayout(
        contents: {
          a!columnsLayout(
            columns: {
              a!columnLayout(
                contents: {
                  a!cardLayout(
                    contents: {
                      a!gridField(
                        label: "Read-only Grid",
                        labelPosition: "ABOVE",
                        data: local!vehicles,
                        columns: {
                          a!gridColumn(
                            label: "Make",
                            value: fv!row.make
                          ),
                          a!gridColumn(
                            label: "Model",
                            value: fv!row.model
                          ),
                          a!gridColumn(
                            label: "Value",
                            value: fv!row.value
                          ),
                        },
                        selectable: true,
                        disableRowSelectionWhen: or(
                          
                          /* allow rows to be un-selected, but no new rows to be selected, when max value is passed */
                          and(
                            not(contains(tointeger(local!selection), fv!identifier)),
                            local!maxValueReached
                          ),
                          
                          /* un-comment the following row to selectively disable rows that would cause max value to be exceeded */
                          /*local!totalValueSelected + fv!row.value > local!valMaxAuto*/
                        ),
                        selectionStyle: "ROW_HIGHLIGHT",
                        selectionValue: local!selection,
                        
                        selectionSaveInto: {
                          
                          /* you can basically just use this - since my example is using a dictionary, the index of the row will be saved -- when using a queried datasubset, you may need to adjust accordingly since the saved value will use the identifier instead */
                          local!selection
    
                        },
                        validations: {}
                      )
                    },
                    height: "AUTO",
                    style: "NONE",
                    marginBelow: "STANDARD"
                  ),
    
                }
              ),
              a!columnLayout(
                contents: {}
              )
            }
          ),
          
          a!paragraphField(
            label:"ri!selectedVehicle",
            value: local!selectedVehicles
          )
        },
        showWhen: true
      )
    )

  • 0
    Certified Senior Developer
    in reply to Mike Schmitt

    Thanks a lot Mike for your reply, but sorry, your code is great but does not reply to my question.
    I need to know why with my little (of course not optimized) example, I'm succeeding in tricking Appian?

    I've tested your code and the issue is exactly the same here:
    If I select successively (and slowly) these 3 rows : Ford, Volvo, Chevy, all works fine, as the last row can not be selected.

    But... If I select very quickly these 4 rows, the issue is still present (as my picture below).
    The code optimization aspect has nothing to do with that strange behavior.

    Is it an Appian bug?

  • 0
    Certified Senior Developer
    in reply to cedric01

    Hi cedric,
    I see no real reason why it should not work.
    i took your code and created a pretty similar code to test it myself. it is working perfectly in my environment.
    can you check if it is behaving the same way in your environment or do you see any difference which are perhaps important for your question? I didnt see anything major different. (our appian verison is 20.2 on premise

    a!localVariables(
      local!product:{"tape","brush","paint","bucket" },
      local!price: {10,20,20,40},
      local!datasubset: a!datasubset(
        startIndex: 1,
        batchsize: 1,
        data: {
          a!forEach(
            items: local!product,
            expression: {
              product:fv!Item,
              price:index(local!price,fv!Index,null)
            }
          )
        },
        identifiers: {1,2,3,4}
      ),
      local!maxPrice: 40,
      local!selection,
      local!selectedProduct,
      a!sectionLayout(
        contents: {
          a!columnsLayout(
            columns: {
              a!columnLayout(
                contents: {
                  a!cardLayout(
                    contents: {
                      a!gridField(
                        label: "Read-only Grid",
                        labelPosition: "ABOVE",
                        data: local!datasubset.data,
                        columns: {
                          a!gridColumn(
                            label: "product",
                            value: fv!row.product
                          ),
                          a!gridColumn(
                            label: "price",
                            value: fv!row.price
                          ),
                        },
                        selectable: true,
                        selectionStyle: "ROW_HIGHLIGHT",
                        selectionValue: local!selection,
                        selectionSaveInto: {
                          local!selection,
                          a!save(
                            target: local!selectedProduct,
                            value: append(
                              local!selectedProduct, 
                              fv!selectedRows
                            )
                          ),
                          a!save(
                            target:local!selectedProduct, 
                            value: difference(
                              local!selectedProduct, 
                              fv!deselectedRows
                            )
                          ),
    
                          a!localVariables(
                            local!maxValueAccepted: if(
                                not(isnull(local!selectedProduct)),
                                sum(
                                  a!forEach(
                                    items: local!selectedProduct,
                                    expression: fv!item.price
                                  )
                                ),
                                0
                            ),
    
                            if (local!maxValueAccepted > local!maxPrice,
                            {
                              a!save(local!selection, remove(local!selection, length(local!selection))), 
                              a!save(local!selectedProduct, remove(local!selectedProduct, length(local!selectedProduct))),
                            },
                            null
                            )
                          ),
    
                          /*a!save(ri!selectedVehicleIds, local!selection)*/
    
                        },
                        validations: {}
                      )
                    },
                    height: "AUTO",
                    style: "NONE",
                    marginBelow: "STANDARD"
                  ),
    
                }
              ),
              a!columnLayout(
                contents: {}
              )
            }
          ),
          a!paragraphField(
            label:"local!selectedProduct",
            value: local!selectedProduct
          )
        },
        showWhen: true
      )
    )

  • 0
    Certified Senior Developer
    in reply to Richard Michaelis

    Hi Richard,

    Thank you for your reply. Unfortunately, I can confirm that I can reproduce the same issue (please see the picture below).

    To reproduce it, you must select very very quickly the 4 lines 10,20,30,40 (then the fourth line is unselected at the end).

    Another way to reproduce it easier, is to select the 40 row line (so total max is reached), and then click quickly on 2 other lines.

    I can reproduce this issue on 2 different Appian environnments, so I don't think it is linked to my environment.


    Another way to reproduce it easily, is to plug the grid on a RecordType with a big table. 

  • 0
    Certified Senior Developer
    in reply to cedric01

    Hi cedric,
    even if i click super quick, starting by the bottom, it is not going to break in my case. absolutly like expected.
    so perhaps a performance issue in your evironment? Are the loading bar appearing? Can you show your performance stats? perhaps we can get a clue there?

Reply Children
No Data