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

How to Create Data Table Dynamically?

SOLVED
Highlighted
Level 1

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

Re: How to Create Data Table Dynamically?

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.

4 REPLIES 4

Re: How to Create Data Table Dynamically?

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.

Re: How to Create Data Table Dynamically?

Thank you so much Carles Coll​,

You saved my time.

Re: How to Create Data Table Dynamically?

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?

Re: How to Create Data Table Dynamically?

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