Skip to main content
December 18, 2024
Solved

Record data does not refresh even refreshOnVarChange is set

  • December 18, 2024
  • 5 replies
  • 0 views

I have a record type called "Case", and it has a field called "assignee".

I also have an interface, in the interface, I have

  • a grid field that show all cases, with multi-selection enabled

  • a dropdown field allow user choose an assignee

  • a button, called "Assign Selected Cases in Batch", after user multi-select cases and select assignee from dropdown, allow user to click this button to assign multiple cases to 1 assignee in 1 click

To do so, I created:

  • a batch assignment process model (works perfectly)

In the interface, I declared:

  • a refresh counter called local!caseDataRefreshCounter, initialize with 0
  • local!cases, as a refresh variable, with refreshOnVarChange set to local!caseDataRefreshCounter, and it is corresponding to the "data" field under my a!gridField

the button widget implementation of "Assign Selected Cases in Batch" is

a!buttonWidget(
  label: "Assign Selected Cases in Batch",
  saveInto: {
    a!startProcess(
      processModel: cons!PDVAL_PM_CASE_ASSIGNMENT,
      processParameters: {
        assignedGroup: null,
        /* Group */
        assignee: local!assignee,
        /* User */
        availableAssignees: local!availableAssignees,
        /* List of User or Group */
        processAction: a!match(
          value: local!availableAssigneeGroup,
          equals: cons!PDVAL_GROUP_PREPARER,
          then: cons!PDVAL_TEXT_PROCESS_ACTION_PREPARER_REASSIGN,
          equals: cons!PDVAL_GROUP_REVIEWER,
          then: cons!PDVAL_TEXT_PROCESS_ACTION_REVIEWER_REASSIGN,
          default: null
        ),
        cases: local!selectedCases/* PDVAL Case */
      },
      onSuccess: {
        a!save(
          local!caseDataRefreshCounter,
          local!caseDataRefreshCounter + 1
        ),
      }
    )
  },
  submit: false,
  validate: false
}

What I expected:

  • everytime user click on the button, after the process model is succeeded, the local!cases get refreshed so the latest assignee could show in the gridfield

However, it is not the case, it does not refresh the data at all, user has to manually refresh the page to get the latest data

Best answer by danielh2593

Sorry I did not even notice there is a refreshOnVarChange attribute under gridField, that is my problem. Btw, local variable of recordData does work in terms of data attribute in gridField.

The solution for my problem is to set refreshOnVarChange under gridField instead of creating a refreshing variable and set refreshOnVarChange 

5 replies

mathieud0001
December 19, 2024

I have 2 questions:

1. Is your process model chained? Does the counter get incremented after the button is clicked?

2. Is there a particular reason why you are not putting the recordData (and refresh) on the grid directly instead of a separate local variable?

This is an example I did for another question

stefanhelzle0001
December 19, 2024

I am not sure why this even works at all. In my understanding, a!recordData only works inside the grid, but not for local variables. We just had this conversation here the other day.

danielh2593AuthorAnswer
December 19, 2024

Sorry I did not even notice there is a refreshOnVarChange attribute under gridField, that is my problem. Btw, local variable of recordData does work in terms of data attribute in gridField.

The solution for my problem is to set refreshOnVarChange under gridField instead of creating a refreshing variable and set refreshOnVarChange 

mathieud0001
December 19, 2024

If you found an answer helpful, please consider marking it as verified.