widget._id != widget.oid ?



  • Avatar
    Moti Granovsky

    Hi John, excellent question!

    All of your assumptions are absolutely correct: the "oid" property is the correct ID to use in all cases. 

    See this screenshot:

    As you can see, the widget's "oid" is the ID used for the widget's URL, for assigning it to a cell in the dashboard layout, and is the one attached to the "widget" DOM element (using this attribute you can determine a widget'd oid, or use jQuery to fetch the container of a given oid)

    This property has been a part of the widget object since the beginning and is there to stay - it should be the one shown in documentation, and I'll review our docs to make sure it is consistently so (you can probably imagine how someone writing the docs could mix those up, though)

    As for why "_id" exists and what it is for: that field represents one instance of the widget. When a dashboard is shared by the owner to any viewers or designers, each user has an instance of the dashboard assigned to them. They all share the same dashboard OID, but each object must have an additional unique key to distinguish those child instances - this way, viewers and designers can modify dashboards shared with them without affecting the owner or other viewers. The same process happens with widgets - as a dashboard is cloned to create a viewer's instance, so are all the widgets contained within it - hence the additional ID field to identify said instance and keep things consistent.

    In 99% of cases you can ignore the "_id" field and should use the "oid" field.

    Hope this helps!

    Comment actions Permalink
  • Avatar
    John Lusk

    Perfect, thanks, Moti!

    Comment actions Permalink

Please sign in to leave a comment.