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

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

How to Create Data Table Dynamically?

magrawal
1-Newbie

How to Create Data Table Dynamically?

Hi Everyone,

I needs to create data table through service. So to perform this I used the createThing snippet of Thingworx as following:

I added a input parameter "Thing_Name" in my service.

var params = {

  name: Thing_Name/* STRING */,

  description: undefined /* STRING */,

  thingTemplateName: "DataTable" /* THINGTEMPLATENAME */,

  tags: undefined /* TAGS */

};

// no return

Resources["EntityServices"].CreateThing(params);

By the above code my Data table is created but What about datashape? How to add it dyamically at the time of Data table creation?

If anyone has idea about it Please help.

Thanks,

Meenakshi

1 ACCEPTED SOLUTION

Accepted Solutions

Hi,

I create a lot of DataTables dynamically, you just need to call Things[newThingName].SetDataShape({ name: "yourDataTableDataShapeName" });

Then do a EnableThing() and a RestartThing()

Carles.

View solution in original post

4 REPLIES 4

Hi,

I create a lot of DataTables dynamically, you just need to call Things[newThingName].SetDataShape({ name: "yourDataTableDataShapeName" });

Then do a EnableThing() and a RestartThing()

Carles.

Thank you so much Carles Coll​,

You saved my time.

This does eventually work (data shape gets set properly), but it causes the following error to be printed in the application log: "Invalid DataShape [] assigned to DataTable TestDataTable". I believe it is because the thing initially gets created without the data shape. Is there a more elegant way to do it without such error?

Hi, No there isn't any other more elegant way of doing it, neither I like it.

Top Tags