Hi there, I'm trying to extract a row from the infotable as per the code below.
var table = me.myInfoTable;
var someRow = table.rows[0];
var result = someRow;
After executing the script I'm getting the following error (composer). Why is that? I'm pretty sure I could do it before.
The infotable is not empty. The data can be accessed by addressing field names.
var someName = someRow.someField;
The output is set to an infotable with the appropriate datashape.
Solved! Go to Solution.
You are not adding the row you got to infotable
you should do as like
var params = {
infoTableName : "InfoTable",
dataShapeName : "testds"
};
var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
var devices = Things["Remote"].GetDataTableEntryByKey({key:'uhii'});
var row = devices.getRow(0);
result.AddRow(row)
You are not adding the row you got to infotable
you should do as like
var params = {
infoTableName : "InfoTable",
dataShapeName : "testds"
};
var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
var devices = Things["Remote"].GetDataTableEntryByKey({key:'uhii'});
var row = devices.getRow(0);
result.AddRow(row)
Nilesh Khose, thank you! It worked.
Although I did not explicitly create a separate infotable using the functions provided, perhaps you could explain why I can access those fields as per the code below?
var someName = someRow.someField;
A method of accessing row fields (without creating a separate table and adding rows to it) is used quite broadly.
The question arises - what is a value collection in the context of ThingWorx? Thanks.
Hi mnudel,
var someRow = table.rows[0];
Here someName is a value collection. In general it's an object or array of different type of elements.
We can refer to elements by <value_collection>.<field_name>.
It is to add a row to an infotable in ThingWorx or refer to an element/cell of an infotable.
I hope it helps.