Skip to main content
vaishalig4654
June 13, 2023
Question

Refresh readonly grid data on button click not working

  • June 13, 2023
  • 8 replies
  • 0 views

Hi,

PFB my code snippet. when i click on button my data in the readonly grid is not refreshing. The source is a expression rule which calls an integration to get the data to display in grid. Kindly provide suggestions.

a!localVariables(
local!currentUser: rule!CORE_GetLoggedInUserName(),
local!refreshCounter: 0,
local!employees: a!refreshVariable(
value: rule!PM_GetCurrentAddresses(
tenantId: "77b50320-5f06-5740-84f4-18d4a8cda51d",
identifierId: local!currentUser,
serviceLocationId: "cac14c53-a058-4824-86dc-f24cea29b948"
),
refreshOnVarChange: local!refreshCounter
),
{
a!buttonArrayLayout(
buttons: {
a!buttonWidget(
label: "Refresh",
size: "SMALL",
style: "SECONDARY",
saveInto: a!save(local!refreshCounter, local!refreshCounter + 1)
)
}
),
a!gridField(
labelPosition: "COLLAPSED",
data: local!employees,
refreshOnVarChange: local!refreshCounter,
columns: {
a!gridColumn(
label: "Address Type",
value: fv!row.addressTypeDescription,
width: "MEDIUM"
),
a!gridColumn(
label: "Address Line 1",
value: fv!row.line1,
width: "MEDIUM"
),
a!gridColumn(
label: "City",
value: fv!row.city,
width: "MEDIUM"
),
a!gridColumn(
label: "State",
value: fv!row.stateDescription,
width: "MEDIUM"
),
a!gridColumn(
label: "Postal Code",
value: rule!CORE_FormatZipCode(fv!row.zip)
),
a!gridColumn(
label: "Effective Date",
value: rule!PM_FormatDate(fv!row.effectiveDate)
),
a!gridColumn(
label: "End Date",
value: rule!PM_FormatDate(fv!row.endDate)
)
}
)
}
)

8 replies

stefanhelzle0001
Brainy
June 13, 2023

vaishalig4654
June 13, 2023

a!localVariables(
  local!currentUser: rule!CORE_GetLoggedInUserName(),
  local!refreshCounter: 0,
  local!employees: a!refreshVariable(
    value: rule!PM_GetCurrentAddresses(
      tenantId: "77b50320-5f06-5740-84f4-18d4a8cda51d",
      identifierId: local!currentUser,
      serviceLocationId: "cac14c53-a058-4824-86dc-f24cea29b948"
    ),
    refreshOnVarChange: local!refreshCounter
  ),
  {
    a!buttonArrayLayout(
      buttons: {
        a!buttonWidget(
          label: "Refresh",
          size: "SMALL",
          style: "SECONDARY",
          saveInto: a!save(local!refreshCounter, local!refreshCounter + 1)
        )
      }
    ),
    a!gridField(
      labelPosition: "COLLAPSED",
      data: local!employees,
      refreshOnVarChange: local!refreshCounter,
      columns: {
        a!gridColumn(
          label: "Address Type",
          value: fv!row.addressTypeDescription,
          width: "MEDIUM"
        ),
        a!gridColumn(
          label: "Address Line 1",
          value: fv!row.line1,
          width: "MEDIUM"
        ),
        a!gridColumn(
          label: "City",
          value: fv!row.city,
          width: "MEDIUM"
        ),
        a!gridColumn(
          label: "State",
          value: fv!row.stateDescription,
          width: "MEDIUM"
        ),
        a!gridColumn(
          label: "Postal Code",
          value: rule!CORE_FormatZipCode(fv!row.zip)
        ),
        a!gridColumn(
          label: "Effective Date",
          value: rule!PM_FormatDate(fv!row.effectiveDate)
        ),
        a!gridColumn(
          label: "End Date",
          value: rule!PM_FormatDate(fv!row.endDate)
        )
      }
    )
  }
)

harshitb6843
June 13, 2023

Instead of changing the counter, why don't you just query the data again and save it in the variable? That will be much easier. Also, make sure that your rule - PM_GetCurrentAddresses, doesn't have a refresh variable configuration. If it has, then set it to refreshAlways: true.