Properties/tags to identify widgets

Comments

3 comments

  • Avatar
    Moti Granovsky

    Hi Brian,

    There is no built in feature for this but I can think of two slightly hack-y solutions:

    One would be to utilize the Description field for widgets, which is often left blank:

    Or, if you do use widget descriptions, you could attach a custom property to the widget object via the widget script:

    When you do the above, and then save the widget, this property will be stored and can be found when getting the widget via API. However, since this is a property that isn't part of the widget object model is might get overridden or removed unexpectedly. You might be able to avoid that, by attaching the custom property to the widget's "style" object, like so:

    widget.style.myCustomProp = 123;

    Making sure not to conflict with any existing properties in there.

    Of course, these approaches are as good as your maintenance discipline - if your designers replace the widget, but forget to both remove this property from the old one and add it to the new one, you're no better off than using the titles. If that doesn't happen, then the widget ID is the most stable, reliable unique identifier and I would generally recommend using it in all other cases except when you actually replace (delete + create new) widgets on a regular basis.

    0
    Comment actions Permalink
  • Avatar
    Brian Wetzel

    I will probably use the widget script.

    Do you know if when a dashboard is copied/cloned do the widgets get new unique ids?  My guess is that they do.  But if they don't then I could just use the widget id

     

    0
    Comment actions Permalink
  • Avatar
    Moti Granovsky

    Hi Brian, the widgets do get new OIDs when cloning a dashboard.

    0
    Comment actions Permalink

Please sign in to leave a comment.