Refresh Variable Not Refreshing

I have the following code snippet from an interface expression that is not updating the refresh variables. I have confirmed that local!refresh updates on record action as it is supposed to, but I cannot get local!selected_tasks or local!expired_tasks. I have tried multiple different configurations of the refresh parameters inside a!refreshVariable() as you can see from all the commented out portions, but none of them seem to work.

I removed all of the record type references in the code, but I assure you they are there in my actual expression.

Any insight would be greatly appreciated.

local!refresh: a!refreshVariable(
  value: rand(),
  refreshAfter: "RECORD_ACTION"
),
  local!selected_process_ids: if(
    a!isNotNullOrEmpty(ri!clientSignOffProcess),
    ri!clientSignOffProcess[],
    null()
  ),
  local!selected_workflow: ri!clientSignOffProcess[],
  local!selected_tasks: a!refreshVariable(
    value: a!queryRecordType(
      recordType: ,
      fields: {
      },
      filters: {
        a!queryFilter(
          field: ,
          operator: "=",
          value: ri!clientSignOffProcess[]
        ),
        a!queryFilter(
          field: ,
          operator: "=",
          value: cons!WSP_WORKFLOW_STATUS_WAITING_ON_CLIENT_SIGNOFF_ID
        )
      },
      pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 50)
    ).data,
    refreshOnVarChange: local!refresh,
    /*refreshAfter: "RECORD_ACTION",*/
    /*refreshAlways: true()*/
  ),
  local!expired_tasks: a!refreshVariable(
    value: a!forEach(
      items: local!selected_tasks,
      expression: if(
        rule!WSP_UTIL_checkIfPacketIsExpiredByWorkflowId(
          fv!item[]
        ),
        fv!item[],
        0
      )
    ),
    /*refreshAfter: "RECORD_ACTION",*/
    refreshAlways: true(),
    /*refreshOnVarChange: local!refresh*/
  ),

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    I sometimes use a technique similar to this, but instead of calling "rand()", I would recommend you call "now()" so that you can view the updated timestamp pertaining to the last time the refresh variable updated.

    Further, be careful as to whether you're assuming any passed-in RI values might refresh due to the refresh variable (they won't, at least not inherently), as well as the refresh behavior of any expression rules you call (when they contain their own local variables).  Aside from those suggestions, I don't know whether we see a complete enough picture of either your setup here, or the resulting behavior, to make many guesses as to the cause of what you're experiencing.  I do stand behind @Shubham's earlier suggestion to cascade refreshes - it looks like you've already incorporated that into the example code you posted.

Reply
  • 0
    Certified Lead Developer

    I sometimes use a technique similar to this, but instead of calling "rand()", I would recommend you call "now()" so that you can view the updated timestamp pertaining to the last time the refresh variable updated.

    Further, be careful as to whether you're assuming any passed-in RI values might refresh due to the refresh variable (they won't, at least not inherently), as well as the refresh behavior of any expression rules you call (when they contain their own local variables).  Aside from those suggestions, I don't know whether we see a complete enough picture of either your setup here, or the resulting behavior, to make many guesses as to the cause of what you're experiencing.  I do stand behind @Shubham's earlier suggestion to cascade refreshes - it looks like you've already incorporated that into the example code you posted.

Children
  • So the process is essentially, Documents are generated and sent to clients to sign > Clients sign when they have time > we upload the signed documents and proceed with more processes.

    To prevent documents from sitting in storage for too long, we have an expiration date for each document. However, due to a poor design we need to work around at the moment, we have to query a table to see if the documents were deleted during a cleanup cron job. 

    So, we have a UI that is calling a record action to regenerate the document. Once the document is regenerated, we can proceed. This is task based, so the user is shown a list of tasks, some of which will have expired docs. 

    The issue here is, when they call the record action to regenerate the documents, we need to re-query the table to refresh the variables that we use to determine which rows need regeneration, but as seen above, that is not happening. I don't really understand why the local!refresh variable is refreshing, but not the cascading variables. We are not expecting the passed-in RI value to change, just the local variables.

    Is there any further details I can provide to assist in a recommendation?

  • 0
    Certified Lead Developer
    in reply to Carey Kitsunari
    we need to re-query the table to refresh the variables that we use to determine which rows need regeneration, but as seen above, that is not happening

    Is the record action process activity-chained all the way through the final DB change(s) that would be expected to get picked up in the refreshed query?  If not, then this setup won't work (as the refresh will take place immediately after chaining breaks, and most likely happen before the final DB writes).  If you could post an overview screenshot of your process flow, that might help.  Certain screenshot tools (i like the freeware "greenshot") allow piecemeal redaction of individual screenshot elements if they contain sensitive info, fwiw.