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

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

SOLVED
Contributor

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.



1 ACCEPTED SOLUTION

Accepted Solutions

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

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

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

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

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

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.

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

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.