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

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


  • 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


  • @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


  • 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.


  • @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.