Facility Control

 View Only
  • 1.  DashBoard Return Button ID

    Posted 12-29-2020 10:49

    Hi,

    I'm looking for a way to return the current button's ID as part of a task, which I would then want to apply a right() function to get the last 3 characters and then set the result as a variable to use in visual logic. 

     

    Any ideas? It may be kind of a stretch based on another post I saw, but I've gotta make a few hundred buttons with some fairly complicated and I wanted to be able to use the button ID (which I have to maintain anyway in order to apply the correct name and style from another script) to feed into a parameter block's index field.

     

    Thanks!



  • 2.  RE: DashBoard Return Button ID

    Posted 01-04-2021 15:54

    I, unfortunately, don't think there's a way of getting the ID of the button that was just pressed.   You could create a variable at the top of the task that has the ID.   I know this is duplicating information, but I can't think of another way right now.


    #DashBoard


  • 3.  RE: DashBoard Return Button ID

    Posted 01-04-2021 22:35

    I think using button parameters might be a better approach to take as you can easily get the selected button's OID and element number (or selected choice). Still, if you'd like to use the <button/> tag, this is how you can get the ID:

    <abs contexttype="opengear" gridsize="20" id="_top">
    <meta>
    <api>function doTheThing(component)
    {
    ogscript.debug("ID: " + component.getClientProperty('id'));
    }
    </api>
    </meta>
    <button buttontype="push" height="100" id="b1" left="80" name="Button 1" top="100" width="240">
    <task tasktype="ogscript">doTheThing(component);

    </task>
    </button>
    <button buttontype="push" height="100" id="b2" left="340" name="Button 2" top="100" width="240">
    <task tasktype="ogscript">doTheThing(component); </task>
    </button>
    </abs>

    #DashBoard