Refresh readonly grid data on button click not working

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)
)
}
)
}
)

  Discussion posts and replies are publicly visible

Top Replies

Parents
  • 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)
            )
          }
        )
      }
    )

  • 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. 

  • 0
    Certified Lead Developer
    in reply to vaishalig4654

    Do you use a local variable in PM_GetCurrentAddresses? If yes, you need to add a refreshvariable using refreshalways set to true.

  • a!localVariables(
      local!pmAddressDetails: rule!PM_EP_CurrentAddressDetails(
        tenantId: ri!tenantId,
        identifierId: ri!identifierId,
        serviceLocationId: ri!serviceLocationId
      ),
      local!data: if(
        local!pmAddressDetails.success,
        local!pmAddressDetails.result.body.results,
        local!pmAddressDetails.error
      ),
      local!primaryAddress: if(
        length(local!data) > 0,
        index(
          todatasubset(
            index(
              local!data,
              intersection(
                wherecontains(
                  true,
                  toboolean(property(local!data, "isActive", ""))
                ),
                wherecontains(
                  "S",
                  touniformstring(property(local!data, "addressType", ""))
                )
              )
            ),
            a!pagingInfo(
              startIndex: 1,
              batchSize: - 1,
              sort: {
                a!sortInfo(field: "endDate", ascending: false()),
                a!sortInfo(
                  field: "effectiveDate",
                  ascending: false()
                )
              }
            )
          ).data,
          1,
          null
        ),
        null
      ),
      local!sortedAddresses: append(
        todatasubset(local!primaryAddress).data,
        if(
          isnull(local!primaryAddress),
          todatasubset(
            local!data,
            a!pagingInfo(
              startIndex: 1,
              batchSize: - 1,
              sort: {
                a!sortInfo(field: "endDate", ascending: false()),
                a!sortInfo(
                  field: "effectiveDate",
                  ascending: false()
                ),
                a!sortInfo(field: "addressType", ascending: true()),
                a!sortInfo(field: "isActive", ascending: false())
              }
            )
          ).data,
          todatasubset(
            remove(
              local!data,
              wherecontains(
                touniformstring(local!primaryAddress.addressId),
                touniformstring(property(local!data, "addressId", ""))
              )
            ),
            a!pagingInfo(
              startIndex: 1,
              batchSize: - 1,
              sort: {
                a!sortInfo(field: "endDate", ascending: false()),
                a!sortInfo(
                  field: "effectiveDate",
                  ascending: false()
                ),
                a!sortInfo(field: "addressType", ascending: true()),
                a!sortInfo(field: "isActive", ascending: false())
              }
            )
          ).data
        )
      ),
      local!sortedAddresses
    )

    This is my code for rule!PM_GetCurrentAddresses where rule!PM_EP_CurrentAddressDetails is my integration call. As per you in rule!PM_GetCurrentAddresses where should i  apply refreshalways set to true.Kindly suggest.

  • pmAddressDetails, and the cascading dependent variables. 

  • Amazing. Please consider verifying the answer so if someone faces the same problem, they can try the working solution. 

Reply Children
No Data