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