Location on infotable issue
I spent some time trying to implement a service that would get a infotable from network connections and add some info from the things in this network.This info would be home mashup and location.
The problem came in the location fied, it would only be set to NaN.
The solution I found was to clone the infotable after the data in it and then add the same data again. Still don't know why.
Here is the code (the "nome_arvore" field is just the name of the things without underscores):
var params = {
maxDepth: undefined /* NUMBER */
};
// result: INFOTABLE dataShape: NetworkConnection
var r = Networks[Network].GetNetworkConnections(params);
var newField = new Object();
newField.name = "nome_arvore";
newField.baseType = 'STRING';
r.AddField(newField);
var newField2 = new Object();
newField2.name = "mashup";
newField2.baseType = 'MASHUPNAME';
r.AddField(newField2);
var newField3 = new Object();
newField3.name = "local";
newField3.baseType = 'LOCATION';
r.AddField(newField3);
var tableLength = r.rows.length;
for (var x = 0; x < tableLength; x++) {
var q = r.rows
.to; q = q.split('');
for (i=1; i<30; i++)
{
if(q == "_")
{
q= " ";
}
}
q = q.join("");
r.rows
.nome_arvore = q; r.rows
.mashup = Things[r.rows .to].GetHomeMashup(); if(Things[r.rows
.to].tipo == "Device") { r.rows
.local = Things[r.rows .to].Local_de_instalação; //r.rows
.local = lo; }
}
var params = {
t1: r /* INFOTABLE */
};
// result: INFOTABLE dataShape: "undefined"
var I = Resources["InfoTableFunctions"].Clone(params);
var tableLength = I.rows.length;
for (var x = 0; x < tableLength; x++){
if(Things[I.rows
.to].tipo == "Device") { I.rows
.local = Things[I.rows .to].Local_de_instalação; }
}
var result = I;
I would like to know why I have to do it.
Thank you,
Marcel

