I have an interface that displays an interface with a form if a local variable is true, else it shows an interface with a grid. The desired behavior is once the user creates an item using the form, the grid will automatically update to display the new item in the grid. It does not do this. The user has to click the grid refresh button to see the new item.
The form saves the item using writeToDataStoreEntity in the saveInto of the submit button. On success, it changes the value of the boolean which causes the grid to appear to the user.
The grid is a record-backed grid. Changing the grid to use a DSE or changing the form to use a record are not allowed. A process model is also not allowed.
Placing the recordData in a local variable and using refreshAfterVarChange does not update the recordData. Using the refreshOnVarChange parameter in the grid does not refresh the data. Placing the grid interface in a local variable with refreshOnVarChange also does not cause the recordData to update.
Since I am changing the boolean only after the writeToDataStoreEntity is successful, I assume the data has been saved to the database before the boolean changes. I would also assume that once the boolean changes, the refreshOnVarChange would cause a!recordData(..) to run again causing the record to retrieve the newly saved item.
Can someone explain why the above logic is wrong and offer a suggestion for how to update the record data?
Below are the relevant parts of the code:
PARENT INTERFACE:
local!viewForm: false,
if( viewForm, rule!myForm(viewForm: local!viewForm), rule!viewGrid(viewForm: local!viewForm))
GRID INTERFACE:
a!cardLayout(contents: link: a!dynamicLink(saveInto: a!save(ri!viewForm, true)),
a!gridField(refreshOnVarChange: ri!viewForm, data: a!recordData(....))
FORM INTERFACE:
a!buttonWidget(saveInto: a!writeToDataStoreEntity(onSuccess: a!save(ri!viewForm, false)
Discussion posts and replies are publicly visible
Your grid in not refreshing because in refreshOnVarChange you directly passed rule input instead of local variable, refreshOnVarChange only works when a local variable change. See the definition below.
refreshOnVarChange (Any Type): Refreshes the grid data each time any of these specific variables change. This allows you to refresh the grid data when a variable that is not referenced in the grid configuration is updated. You can define either using a single variable (e.g. refreshOnVarChange: local!var1) or a list of variables (e.g. refreshOnVarChange: {local!var1, local!var2}).Solution 1-
Thanks for your reply. I updated the code, but it does not work. Here is the update.
GRID INTERFACE
local!viewForm: if(a!isNullOrEmpty(ri!viewForm), false, true),
a!gridField(data: refreshOnVarChange: local!viewForm, data: a!recordData(....))