• 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

    Script error: TypeError: Cannot read property "get" from undefined multistate

    Scripting general Discussion
    3
    4
    1.6k
    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.
    • P
      Pedro
      last edited by

      Thank you for adding the get() function back into the statistics object. I can get it to work for binary data types, but I can't get it to work for multistate data.

      var bulk = 1;
      var stagePastDay = stage.past(DAY);
      var bulkHours = stagePastDay.data.get(bulk).runtime / (1000*60*60);
      return bulkHours;
      

      Script error: TypeError: Cannot read property "get" from undefined in <eval> at line number 3 in <eval> at line number 3
      If I replace "stage" with a boolean datapoint, it works fine.

      I also tried using .getStartsAndRuntime(), but that also did not work. Even the .getStartsAndRuntime() example from the "Mango Java Script" help page did not work.

      How can I obtain the runtime of a given state in a multistate datapoint?
      Have all the examples in the "Mango Java Script" been verified to still work after the changes?
      ma-core 3.5.5
      meta 3.5.0

      1 Reply Last reply Reply Quote 0
      • CraigWebC
        CraigWeb
        last edited by CraigWeb

        @pedro said in Script error: TypeError: Cannot read property "get" from undefined multistate:

        var bulk = 1;
        var stagePastDay = stage.past(DAY);
        var bulkHours = stagePastDay.data.get(bulk).runtime / (10006060);
        return bulkHours;

        The example on the help documents for the .get() is
        return b.past(MONTH, 2).get(false).proportion;
        try remove the .data on your .get call. 0_1541676206564_Screenshot 2018-11-08 at 13.22.36.png

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

          Hi Pedro,

          You're welcome and sorry for the confusion around this. Did you notice somewhere the documentation is incorrect? I will go comment in the referenced thread to make sure it has the correct syntax.

          P 1 Reply Last reply Reply Quote 0
          • P
            Pedro @phildunlap
            last edited by

            @phildunlap @craigweb

            Thank you both. This time the error was mine. I thought the point was multistate, but I now realize it was numeric rendered as a range. So I exported its historic values, changed the point type, then imported the values back in. It works now.

            The containsKey() example in the Mango Javascript help also works. In the past some of the examples did not work or were not consistent with new back-end functionality. I have not checked the other examples.

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