Hi!
I have an issue with refreshing a page. I've got a read-only grid and a delete button. After I choose some of the rows a press delete, which launches "a!startProcess" function; the problem is that I don't know how to refresh or redirect in that case. I have no rule inputs or variables...
Discussion posts and replies are publicly visible
a!startProcess has the onSuccess parameter. This is evaluated as the process is started, or, when activity chaining is enabled, at the end of that chain. Now you can refresh the data in a a!save(), added to onSuccess.
The problem is that the data from the grid is obtained via a query. I tried to set parameter "refreshOnVarChanged" to local!customerIDs (which contains an array of ids of all selected rows). When I press the button I trigger the following function:
saveInto: a!startProcess( cons!CD_DELETE_CUSTOMER_DETAILS, {customerIDs: local!customerIDs}, a!save(local!customerIDs, null) )
but it won't reload the data in the grid, it only unchecks the checkboxes near the deleted rows.
As Stefan mentioned, you need to be using the onSuccess parameter of the startProcess() call to do that save - the way you have it set up now, you're nulling out the customerIds too early, and any refresh that may have happened due to that change will have already happened before any changes caused by the process which you might want refreshed in your local data.
Moving the "a!save(local!customerIDs, null())" to "onSuccess" might work just on its own. But for code clarity, one trick I usually do is to delcare a separate variable i.e. "local!refreshCounter: 0", and then in my "onSuccess", i'll overwrite it with "local!refreshCounter + 1". Then just add that to the "refershOnVarChanged" list wherever needed.
I also use a local!refreshCounter in these cases. The alternative is, to repeat the query inside of onSuccess. But this is duplicate code ...