Sorting not working

Hi ,

In below code default sorting is not working on  UI interface. 

a!gridTextColumn(
label: "Served By",
field: "servedBy",
data:
a!applyComponents(
function: rule!getUserName(_),
array: ri!subset.data.servedBy
)

)

In this we are setting local.paginInfo in load and passing same on ein with() to this dataset subset. Then further this dataset i am passing to another rule where i am keeping grid section. 

After clicking on header column sorting should be work but its not working. Tried lot but not found feasible solution.

  Discussion posts and replies are publicly visible

  • Hi Saurav,

    As per my guess, you are formatting the username by using getUserName() function. If this is right assumption then my answer to your another similar thread  (https://community.appian.com/discussions/f/user-interface/17103/a-gridfield-sorting-issue) might be the cause of incorrect sorting.  (It is on the similar note as of David's comment along with one example). 

    However, can you also post the code of rule - getUserName() which will help us to identify the problem

    Regards,

    Yogesh

  • 0
    Certified Lead Developer
    in reply to sauravk

    Thanks for posting your grid code.  Unless you omitted something from your saveInto by accident, your code will definitely cause you issues because it's not formatted correctly.  This is what I'm seeing, if you can confirm for me:

  • 0
    Certified Lead Developer
    in reply to Mike Schmitt

    , please try the following code in place of your current saveInto code.  I believe your current version is not properly saving the paging info when paging or sorting controls are clicked.

    saveInto: {
      a!save(
        local!gridSelection,
        a!gridSelection(
          pagingInfo: save!value.pagingInfo,
          selected: if(
            count(save!value.selected) > 2, /* if user clicks "select all", keeps previous selection */
            local!gridSelection.selected,
            index(
              save!value.selected,
              count(save!value.selected), /* selects the latest-checked item; safely handles when the selection is un-checked */
              {}
            )
          )
        )
      )
    
    
      /* old code
      local!gridSelection,
      local!gridSelection.selected,
        count(
          local!gridSelection.selected
        ) > 1,
        a!save(
          local!gridSelection.selected,
          local!gridSelection.selected[count(
            local!gridSelection.selected
          )]
        ),
        {}
      ) */       
    }

  • Thanks Mike for your reply. But I have tried this but new issues are coming.

    Pasted here with or without save!value in code. I have used exact your code by replaced existing one.

    Used -save!value
      at function a!gridField: An error occurred while executing a save: Expression evaluation error at function a!gridSelection [line 155]: Could not find variable 'save!value'
     
      Used -local!gridSelection
      Expression evaluation error: The save target must be a load() variable, process variable, or node input (or a rule input passed one of those three), but instead was: [selected=, pagingInfo=[startIndex=1, batchSize=10, sort=[field=data.createdBy, ascending=true]]]

  • 0
    Certified Lead Developer
    in reply to sauravk

    Please post the entire form code again as it exists after you swapped in my saveInto code.  Also, can you please confirm what Appian version you're currently on?

  • I am sorry I had missed one tag a!save(). Now I have replaced this code again but now no paging is working on same page only 10 records are coming as batch size is 10 but its not even moving to next page also.

    saveInto: {
               a!save( local!gridSelection,
                /*if(*/
                  /*count(*/
                    /*local!gridSelection.selected*/
                  /*) > 1,*/
                  /*a!save(*/
                    /*local!gridSelection.selected,*/
                    /*local!gridSelection.selected[count(*/
                      /*local!gridSelection.selected*/
                    /*)]*/
                  /*),*/
                  /*{}*/
                /*),*/
                a!gridSelection(
          pagingInfo: local!gridSelection.pagingInfo,
          selected: if(
            count(local!gridSelection.selected) > 2, /* if user clicks "select all", keeps previous selection */
            local!gridSelection.selected,
            index(
              local!gridSelection.selected,
              count(local!gridSelection.selected), /* selects the latest-checked item; safely handles when the selection is un-checked */
              {}
            )
          )
        ))
               
              },

  • 0
    Certified Lead Developer
    in reply to sauravk

    It won't work like this - you need to use save!value as in my example above, as it holds the entire value gridSelection value being passed back to the saveInto variable.  The way you have it set up here, it will never update paging because you're just overwriting it with its own value for every save operation.  If save!value isn't working for some reason, we need to troubleshoot and figure out why, not just replace it with something that doesn't do the same thing.

    Also: I just realized you're declaring your local!gridSelection in the parent rule and referring to it in the child rule - this works by basic inheritance but I think it might not work when trying to saveInto local!gridSelection from the child.  You really should add a rule input for gridSelection in the child rule and pass in local!gridSelection to it from the parent, then in the child replace any references to local!gridSelection with ri!gridSelection.

  • I had tried both. But atleast with your code paging is working but sorting still have same issue.

     saveInto: {
                /*if(*/
                  /*count(*/
                    /*local!gridSelection.selected*/
                  /*) > 1,*/
                  /*a!save(*/
                    /*local!gridSelection.selected,*/
                    /*local!gridSelection.selected[count(*/
                      /*local!gridSelection.selected*/
                    /*)]*/
                  /*),*/
                  /*{}*/
                /*),*/
               a!save(
        local!gridSelection,
        a!gridSelection(
          pagingInfo: save!value.pagingInfo,
          selected: if(
            count(save!value.selected) > 2, /* if user clicks "select all", keeps previous selection */
            local!gridSelection.selected,
            index(
              save!value.selected,
              count(save!value.selected), /* selects the latest-checked item; safely handles when the selection is un-checked */
              {}
            )
          )
        )
      ),

  • Let me try by passing ri!gridSelection also. Lets check this option also.