Refreshing Record Backed Grid After writeToDataStoreEntity

Certified Lead Developer

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

Parents
  • 0
    Certified Lead Developer

    SOLVED: I solved this issue by creating a counter variable and using the counter variable for the refreshOnVarChange rather than the boolean. I still do not understand why the boolean didn't cause the refresh. The boolean definitely was being updated and worked to display the correct interface. If anyone understands why the boolean didn't work, please let me know.

    Below are the changes I made to get the code to work:

    PARENT INTERFACE:

    local!viewForm: false,

    local!refreshCounter: 0,

    if(

    viewForm,

    rule!myForm(viewForm: local!viewForm, refreshCounter: local!refreshCounter),

    rule!viewGrid(viewForm: local!viewForm, refreshCounter: local!refreshCounter),

    )

    GRID INTERFACE:

    a!cardLayout(contents: link: a!dynamicLink(saveInto: a!save(ri!viewForm, true)),

    a!gridField(refreshOnVarChange: ri!refreshCounter, data: a!recordData(....))

    FORM INTERFACE:

    a!buttonWidget(

    saveInto: a!writeToDataStoreEntity(

    onSuccess: {

    a!save(ri!viewForm, false),

    a!save(ri!refreshCounter, ri!refreshCounter +1)

    }

    )

    )

Reply
  • 0
    Certified Lead Developer

    SOLVED: I solved this issue by creating a counter variable and using the counter variable for the refreshOnVarChange rather than the boolean. I still do not understand why the boolean didn't cause the refresh. The boolean definitely was being updated and worked to display the correct interface. If anyone understands why the boolean didn't work, please let me know.

    Below are the changes I made to get the code to work:

    PARENT INTERFACE:

    local!viewForm: false,

    local!refreshCounter: 0,

    if(

    viewForm,

    rule!myForm(viewForm: local!viewForm, refreshCounter: local!refreshCounter),

    rule!viewGrid(viewForm: local!viewForm, refreshCounter: local!refreshCounter),

    )

    GRID INTERFACE:

    a!cardLayout(contents: link: a!dynamicLink(saveInto: a!save(ri!viewForm, true)),

    a!gridField(refreshOnVarChange: ri!refreshCounter, data: a!recordData(....))

    FORM INTERFACE:

    a!buttonWidget(

    saveInto: a!writeToDataStoreEntity(

    onSuccess: {

    a!save(ri!viewForm, false),

    a!save(ri!refreshCounter, ri!refreshCounter +1)

    }

    )

    )

Children
No Data