Table save refreshes only the rows changed in Skuid?

  • 3
  • Question
  • Updated 5 years ago
  • Answered
When I make changes to records in Skuid and then save, Skuid refreshes the records/rows that I changed and the shows the new data, dependent formulas on those data changes, etc.

However, if someone changes other rows that appear in the table, those rows are not refreshed after I click "Save", unless I, too, have changed those records in Skuid. The data remains stale, not reflecting someone else's changes of those records.

I would have expected that the table would be completely refreshed. Is it working as intended?
Photo of Peter Bender

Peter Bender, Champion

  • 6,246 Points 5k badge 2x thumb

Posted 5 years ago

  • 3
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Yes, this is the intended design - the thought is that when you are editing records, refreshing all other rows in the table, not just the rows you modified, slows down the total operation; more rows have to be retrieved, and more of the table has to be rebuilt client-side.

That being said, your concern about the other rows being stale is totally valid. We are considering adding in a property to Save actions in Skuid allowing for Models to be completely refreshed after Save --- not just the original Model, but other Models as well. For instance, if you have a Table of Detail records on a page, as well as the primary/Master record, and there are Roll-up Summary fields on the Master, then you'd expect that the Master record would be updated whenever any records in the Detail model are modified/created/deleted. Rather than Skuid forcing that upon you, what we'd like to do is to allow you to customize exactly what happens on Save.

Currently, if you'd like to achieve this, you can use the Skuid JavaScript API to "link" together your Models --- you can register "listeners" on Models, saying things like:
(a) "Whenever my Detail Model (i.e. Opportunity Line Items) is Saved, I want to force a refresh of my Master (i.e. Opportunity) model, as long as there are not unsaved changes"
(b) "Whenever my Save this Model, which I expect to only have one row, then if that row is brand-new, I want to go set some Conditions on 3 other models using the Id of that newly-created row, and then force a refresh of those 3 Models."

Here's an example of how you could do (a), using a JavaScript Resource of type "Inline". Here's what the Resource Body would be, assuming that your "Master" model is called "Master", and your detail model is called "Detail":




skuid.$(function(){

// Whenever our Detail model is Saved,
// we want to refresh our Master model,
// but only if there are no unsaved changes
// to the Master model
var DetailListener = new skuid.ui.Editor();

var DetailModel = skuid.model.getModel('Detail');
var MasterModel = skuid.model.getModel('Master');

DetailListener.registerModel(DetailModel);

// Specify what we want to do
// when the Detail Model finishes saving
DetailListener.handleSave = function(totalSuccess) {
if (totalSuccess) {
// Only update the Master model
// if it does NOT have unsaved changes
if (!MasterModel.hasChanged) {
MasterModel.updateData();
}
}
};

});

Photo of Jessica Shier

Jessica Shier

  • 208 Points 100 badge 2x thumb
I am not sure if this is what I am looking for but I think it is. I have a child on Opportunity called Tenor. If a Tenor is incomplete I want it showing up in a table for Incomplete Tenors. I got this far. The missing fields are displayed in the table and the User can Edit them using a Mass Edit for selected rows.

Once they save the rows they edit I want the Opp to refresh so that the table of incomplete Tenor Records shrinks. I added the above snippet (modified for my model) to the JavaScript resources but I am assuming I need to add it somewhere to be run. I just don't know where!
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
See the answer to this Community question for how to do what Jessica is asking: to update the same Model whenever it is saved.