Forced Refresh Every Hour?

Here’s the approach we’re using that builds on the approaches above, but the code is parameter driven and reusable. We use a UI only model that generates a row on load and has a field with default values for a pollModel, an updateModel and an interval (in seconds) (see Screenshot). Then there is a Model action when a row is created it runs the snippet below. The argument passed into the snippet is the row created when the model is loaded.

Here’s the snippet:

var params = arguments[0],
$ = skuid.$;
pollmodel = params.row.PollModel;
updatemodel = params.row.UpdateModel;
pollinterval = params.row.Polling_Interval;
checkModel = skuid.$M(pollmodel);
updateModel = skuid.$M(updatemodel);
$(function(event){
// THe names of the Models that should be checked every so often for updates
// These should NOT be the Models associated with Charts / Tables, etc.
var RECENT_UPDATES_MODELS = [
pollmodel
];
// Each of our Models should have a Condition named “LastModifiedDate”
var COMMON_CONDITION_NAME = “LastModifiedDate”;
var milliseconds = pollinterval * 1000;
var RecentUpdates = $.map(RECENT_UPDATES_MODELS,function(modelId){ return skuid.$M(modelId); });

setInterval(function(){
var now = new Date();
var previous = new Date(now.getTime() - milliseconds);
$.each(RecentUpdates,function(i,model){
var condition = model.getConditionByName(COMMON_CONDITION_NAME,true);
var sfDateTime = skuid.time.getSFDateTime(previous);
model.setCondition(condition,previous);
});
$.when(skuid.model.updateData(RecentUpdates))
.done(function(){
var foundModelWithUpdates = false;
$.each(RecentUpdates,function(i,model){
if (model.getRows().length) {
foundModelWithUpdates = true;
}
});
if (foundModelWithUpdates) {
var modelsToUpdate = ;
if (checkModel && checkModel.getRows().length && updateModel) {
modelsToUpdate.push(updateModel);
}
$.when(skuid.model.updateData(modelsToUpdate))
.done(function(){
//Placeholder for future post update actions
});
}
});
},milliseconds);
});