cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Extracting data from an infotable. Error: Unable To Convert From .ValueCollection to INFOTABLE.

Michail
10-Marble

Extracting data from an infotable. Error: Unable To Convert From .ValueCollection to INFOTABLE.

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.



ACCEPTED SOLUTION

Accepted Solutions
nkhose
12-Amethyst
(To:Michail)

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)

View solution in original post

3 REPLIES 3
nkhose
12-Amethyst
(To:Michail)

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)

Michail
10-Marble
(To:nkhose)

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.

ankigupta
12-Amethyst
(To:Michail)

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.

Announcements


Top Tags