Site Page title with a!refreshVariable

I have inserted the following piece of code in order to show always the updated number of available tasks to the users.

=a!localVariables(
 local!report: a!refreshVariable(
  value: a!queryProcessAnalytics( 
   report: cons!IOC_USER_TASK_REPORT,
   contextProcessModels: {
    cons!IOC_PROCESS_MODEL_NOTIFICATIONS
   },
   query: a!query(
    pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 1000),
    filter: a!queryFilter(
     field: "c1",
     operator: "<>",
     value: 2 
   )
  )
 ),
 refreshInterval: 0.5
),
"Workflows (" & length(
local!report.data
) & ")"
)

Sadly enough, the automatic refreshing is not working at all. Is this an expected behavior or there is something wrong with this code?

I am running on Appian Cloud 19.2

  Discussion posts and replies are publicly visible

Parents
  • +1
    Certified Lead Developer

    2 things:

    1. this code would only work in an Interface, not an expression used elsewhere (as mentioned by previously).  If you look up the documentation for a!refreshVariables, it tells you that all optional parameters are ignored when used outside of the context of an interface, which would include the refresh interval.
    2. Even if you are using an interface, I discovered a bug (which still hasn't been fixed apparently) where, in the Interface Editor specifically, an auto-refreshing variable won't auto-refresh at all if it's either the ONLY local variable, or the FIRST local variable declared.  If the only local variable you need is the auto-refreshing one, then to get it to apparently work correctly within Interface Editor you should define a "spare" local variable before the auto-refreshing one.
  • Hi Mike,

    Thanks for the info.

    Could you please post sample code snippet for the 2nd point you mentioned?

    Thanks in advance.

  • 0
    Certified Lead Developer
    in reply to Rajesh Mahenderkar

    - here you go. In this example, the auto-refreshing variable (when it's the first/only one) will never auto-refresh.  However if you un-comment the commented-out "override" local variable above it, and press "test" to start fresh, it will work as expected.

    a!localVariables(
      /* local!override: "testing", */
    
      local!firstVariable: a!refreshVariable(
        value: now(),
        refreshInterval: 0.5
        /* will never refresh unless/until the local!override variable is un-commented. */
      ),
    
      a!formLayout(
        label: "Variable AutoRefresh Test",
        contents: {
          a!textField(
            label: "RefreshTime",
            readonly: true(),
            value: text(local!firstVariable, "yyyy/mm/dd hh:mm:ss"),
          )
        }
      )
    )

  • Hi Mike,

    This does not work

    a!localVariables(
      local!startTime: now(),
      local!lastUpdated: a!refreshVariable(
        value: now(),
        refreshInterval: 0.5
      ),
      {
        a!textField(
          label: "Last Updated",
          value: local!startTime,
          readOnly: true
        ),
        a!textField(
          label: "Last Updated",
          value: local!lastUpdated,
          readOnly: true
        )
      }
    )
    

    This does work

    a!localVariables(
      local!fixAppianBrokenFunctionality: "Please",
      local!startTime: now(),
      local!lastUpdated: a!refreshVariable(
        value: now(),
        refreshInterval: 0.5
      ),
      {
        a!textField(
          label: "Start Time",
          value: local!startTime,
          readOnly: true
        ),
        a!textField(
          label: "Last Updated",
          value: local!lastUpdated,
          readOnly: true
        )
      }
    )
    

    So having a first order local var that is referencing text seems to work whereas referencing now() does not.

  • 0
    Certified Lead Developer
    in reply to jeromew

    Interesting, thanks for making the distinction - I didn't realize that the behavior was different depending on the data type of the initial local variable - I obviously didn't test that robustly after discovering the bug ;-)

  • Hi Mike,

    I'm also noticing that once a button is pressed on form (even though it doesn't submit the form) the interval refresh variables seem to stop working.

  • 0
    Certified Lead Developer
    in reply to jeromew

    Interesting... under what conditions?  I just added a buttonWidget to basically the same test form as linked above (it doesn't save into anything but is clickable), and for me at least the autorefresh does continue happening correctly.  But you might be doing something differently.

Reply Children
No Data