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 called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

How to import data-entries to thingworx Datatable through extension

pbadgujar
5-Regular Member

How to import data-entries to thingworx Datatable through extension

We have the DataTables defined in our application.And the applcation is imported as thingworx-extension. We need the dataTable to have default data rows i.e. some entries prepopulated.

Is it possible to export and import data as xml (seems only binary is suuported)? Is there any other way to load data to Datatables through extension

5 REPLIES 5

I am also looking for a solution. I am thinking of having JSON/CSV/XML file within my extension which I can read and populate as data in Data table. I am wondering how do I call this once after installing my extension. Any thoughts??

You could consider having a script with embedded JSON inside a ServiceHelper script and run that.

I have do this a few times- Having an additional import can often get missed and have a script that initializes can be quite helpful.

Snippet example - example

var table = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);

table.AddRow({ "startCount":1500, "createCount":1, "thingName":"BOX1", "model":"XBOX1", "make":"MS","family":"MICS", "dealer":"DC01", "customer":"CUST01", "device":"PLG01",  "SerialNumber":"1000000", "Identifier":"I000000","groupName":"MGROUP", "groupPrivate":true});

table.AddRow({ "startCount":15100, "createCount":2, "thingName":"BOX2", "model":"XBOX2", "make":"MS","family":"MICS", "dealer":"DC01", "customer":"CUST01", "device":"PLG01",  "SerialNumber":"1000000", "Identifier":"I000000","groupName":"MGROUP", "groupPrivate":true});

table.AddRow({ "startCount":15200, "createCount":3, "thingName":"BOX3", "model":"XBOX3", "make":"MS","family":"MICS", "dealer":"DC01", "customer":"CUST01", "device":"PLG01",  "SerialNumber":"1000000", "Identifier":"I000000","groupName":"MGROUP", "groupPrivate":false});

.

.

.

.

Thanks Steve. It makes sense. How do I automatically trigger my service to load the data?

Varathan

Good question,

I would consider creating a Checker Mashup that could be run by Admin  after importing and used to check the state of the import etc and inside that is a HelperService to check and decide if the Database has been loaded or even provide a Button to execute the service.(adding are you sure :-)  )  Might seem a little over kill but an Administrator would probably appreciate a Checkup setup.

Or you could just add it to the Main Mashup and check on Mashup Loaded - but that would always be executing and seems overkill and redundant after first time run.



I am thinking of adding a Boolean property which by default false. On Thing Start of my Data Table subscription, I will check whether my count matches or other validation. If not I can load the data. Then I can set the flag to true. From next time onwards, the flag will be true so my code will skip the entire piece of loading logic.

I am going to see whether I can disable Subscription from its own code. That way the need for the flag can be eliminated.

Thanks,

Varathan

Top Tags