I was under the impression that I could declaratively set a model to listen for changes in records that may be happening by other users. For example, if I am work with a contact record and another person on my team is working on that same record, Skuid could “Sense” an insert, upsert, or delete action on a record and trigger an action sequence. I don’t see that anywhere. Is that a thing?
I haven’t heard of this but it would be really neat for sure.
I must have been dreaming, But it is a neat concept. A clone model that requires every minute but only queries records with a modified date that is newer than the time of the most resent query of the actual model being used on the page. You could easily create it yourself with skuid if you could create an action loop with a delay. Can you do that with branch logic?
There’s not a way to do this declaratively. If you want to detect changes, we recommend setting up an additional model for the object(s) and use a snippet that re-queries that model periodically to check for changes with the source model.
When the second model is re-queried you can set up the logic that evaluates (e.g. if the timestamp has been updated) and the actions to run.
You can check out this page in Skuid labs for an example of what this can look like: https://github.com/skuid/skuid-labs/tree/master/experiments/snippets/realTimeOppDashboard
- This page uses a simple snippet that polls an "updates indicator" model periodically. If this model returns data, the user is warned that there is new data, and they can update the page as they see fit.
- It is not wise to simply continuously poll the primary model. While the model is polling, all components connected to it are frozen (no updates can be made in the UI). Also, unsaved changes in the model would likely be discarded every time the polling action occurred. That could get really annoying.
This would be a very nice standard option to include for all models. The additional code to do so would fairly easy to implement. You already do something quite similar with the page builder when two users have the same page open.
This looks great! Thanks.
This code from Cody Taylor makes it so easy! Just add this code as an inline snippet and change the model name from MyModel to the name of your model. Then create an event triggered action sequence of type Skuid Page: Rendered that runs the snippet.
// To be used as an inline snippet
var model = skuid.$M(‘MyModel’),
refreshInSeconds = 5;
if (model) setInterval(function () {
model.updateData();}, refreshInSeconds * 1000);
https://github.com/skuid/skuid-labs/blob/master/experiments/snippets/timedModelRefresh/standalone.js
Probably the easiest and most flexible way to implement this as a standard feature would be a setting on the model for “periodically refresh model” and then an interval input box. Everything else can be built declaratively already. I’m using he code above from Cody and it is working great.
Oh… one more thing… a setting for “if model changes are detected, run this action sequence”
Me again! Better idea. Instead of a setting for “refresh model” instead a setting “check for changes” and an interval I put. Then skuid would periodically rerun a second query hidden from the user and compare to the current records in the model. If changes are detected, it would run a user defined action sequence.
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.