• Recent
    • Tags
    • Popular
    • Register
    • Login

    Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website Mango 5 Documentation Website

    Querying point hierarchy list from global script

    Scheduled Pinned Locked Moved User help
    3 Posts 2 Posters 1.1k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • I Offline
      iperry
      last edited by

      Hi,

      I was wondering if there is a function available for querying the point hierarchy from a global script, similar to DataPointQuery?

      Also, are there any docs regarding the functions/methods that are available in the global scripts, like DataPointQuery?

      Thanks
      Ian

      1 Reply Last reply Reply Quote 0
      • phildunlapP Offline
        phildunlap
        last edited by phildunlap

        Hi Ian,

        All the functions that would be available in other scripting environments would be available in the global script environment. For instance

        var rootFolders = JSON.parse( JsonEmport.getConfiguration("pointHierarchy") )["pointHierarchy"];
        print( rootFolders );
        

        which will export the hierarchy, then parse it into a javascript object. You could manipulate that however you wanted.and reimport with

        JsonEmport.doImport( {"pointHierarchy": rootFolders } );
        

        Methods available to JavaScript are most definitively found here: https://github.com/infiniteautomation/ma-core-public/blob/main/Core/web/WEB-INF/dox/mangoJavaScript.htm

        Alternatively you could get the PointHierarchy right from the code, then you could use its methods. Like,

        function printContextPointPath( cxtPnt ) {
          print( com.serotonin.m2m2.vo.hierarchy.PointHierarchy.getPath( cxtPnt.getDataPointWrapper().getId(), 
                 com.serotonin.m2m2.db.dao.DataPointDao.instance.getPointHierarchy( true ).getRoot() ) );
          //# use getPointHierarchy( false ) if you're going to modify it and call the DPD's savePointHierarchy method.
        }
        printContextPointPath(p);
        

        Methods in point hierarchies and point folders are in these classes: https://github.com/infiniteautomation/ma-core-public/tree/main/Core/src/com/serotonin/m2m2/vo/hierarchy

        1 Reply Last reply Reply Quote 0
        • I Offline
          iperry
          last edited by

          Great thanks! I will try that out.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post