refreshAlways:true in grid is not working .

According to mentioned code it removes Rows (Deactivates some records) but re

a!localVariables(
  local!pagingInfo: a!pagingInfo(
    startIndex: 1,
    batchSize: 5,
    sort: a!sortInfo(field: "userName", ascending: true)
  ),
  local!Members: cast(
    'type!{urn:com:appian:types:WFM}WFM_Test?list',
    rule!WFM_getTestByTestId(testId: ri!testId)
  ),
  {
    a!gridField(
      label: "Member List",
      labelPosition: if(ri!showLabel,"ABOVE","COLLAPSED"),
      data: local!Members,
      refreshAlways: true(),
      refreshAfter: "RECORD_ACTION",
      columns: {
        a!gridColumn(
          label: "Member Name",
          sortField: "userName",
          value: a!forEach(
            items: fv!row.userName,
            expression: rule!OCO_getUserFullNameFromUserName(userName: fv!item)
          )
        ),
       
        a!gridColumn(
          label: "Remove",
          showWhen: not(ri!readOnly),
          value: a!richTextDisplayField(
            value: a!forEach(
              items: fv!row.MemberId,
              expression: a!richTextIcon(
                icon: if(
                  contains(ri!removedMemberIds, tointeger(fv!item)),
                  "check-square-o-alt",
                  "square-o"
                ),
                altText: if(
                  contains(ri!removedMemberIds, tointeger(fv!item)),
                  "Undo Removal",
                  "Mark for Removal"
                ),
                caption: if(
                  contains(ri!removedMemberIds, tointeger(fv!item)),
                  "Undo Removal",
                  "Mark for Removal"
                ),
                link: a!dynamicLink(
                  saveInto: {
                    a!save(
                      ri!removedMemberIds,
                      if(
                        contains(ri!removedMemberIds, tointeger(fv!item)),
                        remove(
                          ri!removedMemberIds,
                          wherecontains(tointeger(fv!item), ri!removedMemberIds)
                        ),
                        append(ri!removedMemberIds, fv!item)
                      )
                    )
                  }
                ),
                color: if(
                  contains(ri!removedMemberIds, tointeger(fv!item)),
                  "NEGATIVE",
                  "SECONDARY"
                ),
                size: "MEDIUM"
              )
            )
          ),
          width: "NARROW",
          align:"CENTER"
        )
      },
      pageSize: local!pagingInfo.batchSize,
      showWhen: a!isNotNullOrEmpty(ri!testId)
    )
  }
)
fresh behaviour is not working .. tried adding refresh always true also but no luck.

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    Hi your data is in a local variable which you are using to populate the grid on the save into of your dynamic link you are saving the data into rule input so it is obvious that the data will not get refreshed in the local variable are you performing any action after taking the IDs to rule input?

    One better way of doing this can be you can add one more column to your  CDT named as isActive with boolean dataType and when you click on the remove button you can simply mark that to false that would simplify things a lot.

  • 0
    Certified Senior Developer

    As per your code, you are trying to refresh the grid data by record action and refresh always to true but the refresh after will work if you are using records as a data. so now as you may are using query entity so on your local variable you have to use refresh variable and refresh always to true under your refresh variable configurations. 

  • This may be an interesting one to do some more testing on.  In my recent experience (currently on Appian 21.1), I ran into this scenario - using grid data from a rule would not refresh no matter what I used for settings, when I was trying to refresh it always.  I was forced to essentially duplicate the rule's queryEntity directly in the grid's data parameter (or via local variable with the query directly), to get it to refresh properly.  At the time, I couldn't find anything in the documentation on this behavior.  Wonder if others have run into this also ?

    Due to this, my assumption here is that the below will not work, and you will need to pull the queryEntity into your local var directly.

      local!Members: a!refreshVariable(
        value: cast(
          'type!{urn:com:appian:types:WFM}WFM_Test?list',
          rule!WFM_getTestByTestId(testId: ri!testId)
        ),
        refreshAlways: true,
      ),

  • Of course in my scenario, the form is inserting to the DB before trying to refresh, which doesn't appear to be the case here.  But, would still apply if the data in the rule was becoming updated and needed to pull in Upside down