Skip to main content
May 2, 2024
Question

Refresh a!queryProcessAnalytics() when changing referenced variable not working

  • May 2, 2024
  • 6 replies
  • 0 views

Hi everyone, 

I'm having a grid field that shows data from a process model based report by using a!queryProcessAnalytics() query. I set up a manual refresh button that updates a reference local variable's value (local!refreshCounter), so that whenever user clicks the refresh button, the report value will be updated if there is any new active process task. 

However, the process was not refresh unless I refresh the whole page (F5).

I'm I doing it wrong?

a!localVariables(
  local!refreshCounter: 1,
  local!datasubset: a!refreshVariable(value: a!queryProcessAnalytics(
    report: ,
    contextProcessModels: ,
    query: a!query(
      pagingInfo: a!defaultValue(ri!pagingInfo,a!pagingInfo(1,-1)),
      logicalExpression: a!queryLogicalExpression(
        operator: "AND",
        logicalexpressions: {
          a!queryLogicalExpression(
            operator: "AND",
            ignorefilterswithemptyvalues: true,
            filters: 
            /*Status */
            a!queryFilter(
              applyWhen: and(a!isNotNullOrEmpty(ri!statusFilterOperator),
              a!isNotNullOrEmpty(ri!statusFilterValue)),
              field: "c1",
              operator: ri!statusFilterOperator,
              value: ri!statusFilterValue 
            )
          )
        },
        ignorefilterswithemptyvalues: true
      )
    )
  ),
  refreshOnVarChange: local!refreshCounter),
  local!reportData: {
    startIndex: local!datasubset.startIndex,
    batchSize: local!datasubset.batchSize,
    sort: ri!pagingInfo.sort,
    totalCount: local!datasubset.totalCount,
    identifiers: local!datasubset.identifiers,
    data: a!forEach(local!datasubset.data,cast(
      typeof('type!{urn:com:appian:types:'()),
      fv!item)
    ),
    columnConfigs: local!datasubset.columnConfigs
  },
  {a!buttonArrayLayout(
    align: "END",
    buttons: {
      a!buttonWidget(
        label: "",
        tooltip: "Refresh",
        size: "SMALL",
        color: "ACCENT",
        icon: "refresh",
        style: "GHOST",
        saveInto:{
        a!save(local!refreshCounter,local!refreshCounter + 1)
        }
      )
    }
  ),
  a!gridField(
    pagingSaveInto: a!save(local!refreshCounter,local!refreshCounter + 1),
    borderStyle: "STANDARD",
    initialSorts: a!sortInfo(field: "c1",ascending: true),
    label: "Process Tasks",
    emptyGridMessage: "No Active Process",
    labelPosition: "COLLAPSED",
    data: local!reportData.data,
    columns: {
  }
)

    6 replies

    May 3, 2024

    [mention:9974f421d27e4df8bbf583e955409867:e9ed411860ed4f2ba0265705b8793d05] Could you please verify if you've examined refreshOnReferencedVarChange and also consider looking into refreshInterval? I'm just trying to assist you here.

    daniell
    May 3, 2024

    It looks like the a!refreshVariable is set up correctly, but a!queryProcessAnalytics has always had weird behaviors so it doesn't surprise me if it's not working as expected. What happens if you update the saveInto on your button to do a!save(local!datasubset, a!queryProcessAnalytics(...))?

    May 3, 2024

    [mention:89ec515a02ff4fa28317edeb40cf0a4d:e9ed411860ed4f2ba0265705b8793d05] : I just tried with test process report. Please check below  image 

    Interface:

    Expression: