Listen to changes in a records by other users?

Skuidward Tentacles (Raymond)Skuidward Tentacles (Raymond) ๐Ÿ’Ž๐Ÿ’Ž
edited June 26, 2020 in Questions
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?


0
0 votes

Awaiting Review ยท Last Updated

Comments

  • Pat VachonPat Vachon ๐Ÿ’Ž๐Ÿ’Ž๐Ÿ’Ž
    edited June 25, 2020
    I haven't heard of this but it would be really neat for sure.ย 
  • Skuidward Tentacles (Raymond)Skuidward Tentacles (Raymond) ๐Ÿ’Ž๐Ÿ’Ž
    edited June 10, 2020
    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?
  • Anna WiersemaAnna Wiersema ๐Ÿ› ๏ธ ๏ปฟ
    edited June 26, 2020
    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.
  • Pat VachonPat Vachon ๐Ÿ’Ž๐Ÿ’Ž๐Ÿ’Ž
    edited June 26, 2020
    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.
  • Skuidward Tentacles (Raymond)Skuidward Tentacles (Raymond) ๐Ÿ’Ž๐Ÿ’Ž
    edited June 29, 2020
    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.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!