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

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Creating InfoTable Problem

lwei
1-Newbie

Creating InfoTable Problem

Hi, guys!

I've got some problems when I create a infotable.

Here is the following service I use:

var infotable1Object = {dataShape: {fieldDefinitions :{} }, rows: [] };

infotable1Object.datashape.fieldDefinitions['name']={name: 'name', baseType: 'STRING'};

infotable1Object.datashape.fieldDefinitions['value']={name: 'value', baseType: 'STRING'};


var newROW= new Object();

newROW.name="abcde";

newROW.value="12345";

infotable1Object.rows[0]=newROW;

var params = {

  json: infotableObject /* JSON */

};


// result: INFOTABLE

var result = Resources["InfoTableFunctions"].FromJSON(params);

the result is always:

TypeError: Cannot read property "fieldDefinitions" from undefined (CreateInfo#1)

6 REPLIES 6
PaiChung
22-Sapphire I
(To:lwei)

The easiest way to create an infotable would be to define a DataShape and then use CreateInfoTable from DataShape

Fool Proof that way!

If you do a straight up infotable, use AddField instead of the definitions as you are calling.

I believe someone posted a really nice piece already in the community or in a blog on infotables.

lwei
1-Newbie
(To:PaiChung)

Hi, Pai.

Thanks for the information, but the isn't from me.

It is from PTC, thingworx market's  CSV file.

There is a PDF file that show me the example of how to write a CSV file.

But it just can't work. I'm confused.

http://marketplace.thingworx.com/wp-content/uploads/2015/09/CSV-Parser-Extension-User-Guide.pdf

Aanjan
9-Granite
(To:lwei)

Lee, another quick thing - you've used var infotable1Object, but in the json content you've used infotableObject instead.

lwei
1-Newbie
(To:Aanjan)

Hi, Aanjan

  After I fix the bug, it stills result TypeError: Cannot read property "fieldDefinitions" from undefined (WriteCSV#3)

PaiChung
22-Sapphire I
(To:lwei)

Found the post by Bill

Getting to Know Infotables

lwei
1-Newbie
(To:lwei)

Guys, I found out the problem, a stupid mistake!

Thanks, though.

Top Tags