Auto-refresh Local Variable via Asynchronous Process

All,

Let's say I have an interface with a button widget, which triggers an asynchronous process (i.e., a!startProcess). There's also a local variable (let's call it local!myVar) that is initially empty. My goal is to display the value of this variable when it's updated. The asynchronous process is to determine what value gets assigned to this local variable. And I'm looking for ways to display this value without having to reload/leave the interface.

From what I understand, the use of a!refreshVariable() is probably the best way to make this work, but I'm having some difficulties figuring out how to pass a dynamically assigned value within the asynchronous process back to the interface.

Any tips/pointers will be much appreciated!

  Discussion posts and replies are publicly visible

Parents
  • I'd suggest using your a!refreshVariable() to query the data periodically. The main thing you have to figure out is where you need to query. When you update a variable in your process, does it only get updated in the process or do you also save the result to a database table?

    If it only gets updated in your process, you can use the a!queryProcessAnalytics() function. This enables you to query directly from process instances and return their data. In this case, I'd suggest having a!startProcess() return back the process ID. Then, you can use a!queryProcessAnalytics to query the process with the ID provided.

    If you also update the data in the database, you can also use a!queryEntity() to query the data from the database in your refresh variable.

    Assuming you go with the first option, there are several steps you will need to do:

    1) Make sure you return the process ID from a!startProcess() by saving the data from fv!processInfo the "onSuccess" parameter.

    2) Create a process report to return information about the process model you kick off.

    3) Set up your refresh variable like this to query from the process:

    a!localVariables(
      local!processInfo,
      /* This variable should be updated with the onSuccess parameter from a!startProcess() */
      
      local!processStatus: a!refreshVariable(
        value: a!queryProcessAnalytics(
          report: cons!YOUR_REPORT_HERE,
          query: a!query(
            pagingInfo: a!pagingInfo(
              startIndex: 1,
              batchSize: 1
            ),
            filter: a!queryFilter(
              field: "c0",
              /* You might have to change this depending on which column is the ID in */
              /* your process report */
              
              operator: "=",
              value: local!processInfo.pp.id
            )
          )
        ),
        refreshInterval: 1
      )
      ...
    )

Reply
  • I'd suggest using your a!refreshVariable() to query the data periodically. The main thing you have to figure out is where you need to query. When you update a variable in your process, does it only get updated in the process or do you also save the result to a database table?

    If it only gets updated in your process, you can use the a!queryProcessAnalytics() function. This enables you to query directly from process instances and return their data. In this case, I'd suggest having a!startProcess() return back the process ID. Then, you can use a!queryProcessAnalytics to query the process with the ID provided.

    If you also update the data in the database, you can also use a!queryEntity() to query the data from the database in your refresh variable.

    Assuming you go with the first option, there are several steps you will need to do:

    1) Make sure you return the process ID from a!startProcess() by saving the data from fv!processInfo the "onSuccess" parameter.

    2) Create a process report to return information about the process model you kick off.

    3) Set up your refresh variable like this to query from the process:

    a!localVariables(
      local!processInfo,
      /* This variable should be updated with the onSuccess parameter from a!startProcess() */
      
      local!processStatus: a!refreshVariable(
        value: a!queryProcessAnalytics(
          report: cons!YOUR_REPORT_HERE,
          query: a!query(
            pagingInfo: a!pagingInfo(
              startIndex: 1,
              batchSize: 1
            ),
            filter: a!queryFilter(
              field: "c0",
              /* You might have to change this depending on which column is the ID in */
              /* your process report */
              
              operator: "=",
              value: local!processInfo.pp.id
            )
          )
        ),
        refreshInterval: 1
      )
      ...
    )

Children
No Data