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

How to insert value to column in Data table

Highlighted
Garnet

How to insert value to column in Data table

I want to create data table but i can't insert to next column how i can do

11111.png

Tags (1)
6 REPLIES 6
Highlighted

Re: How to insert value to column in Data table

you want to insert data in next "ROW" or add new "COLUMN"?

for new "ROW" - use AddDataTablEntries service.

for new Column - Edit its DataShape and add the required one.

Highlighted

Re: How to insert value to column in Data table

I want to add new COLUMN

Highlighted

Re: How to insert value to column in Data table

Nuttapol Pomtong​ : To add column to your DataTable (DT) you will have to update your DataShape(DS). You can edit the associated DS used by DT and add required field using Field Definitions in DS.

-Durgesh

Highlighted

Re: How to insert value to column in Data table

Are you saying you are creating an InfoTable and you want to add a column to that InfoTable?

If so use AddField

If you are actually working with a DataTable, you can only insert what is defined in its datashape.

use Add or AddOrUpdate DataTableEntry (ies)

Highlighted

Re: How to insert value to column in Data table

Do you have any example code for Add or AddOrUpdate DataTableEntry (ies)?

Highlighted

Re: How to insert value to column in Data table

Nuttapol, are you looking for something like this

Here SpeedDTDemo is my dataTable on which i am doing single entry insert using the AddDataTableEntry service

var values = Things["SpeedDTDemo"].CreateValues();

values.SpeedVal = inputVal; //NUMBER [Primary Key]

var params = {

sourceType: undefined /* STRING */,

values: values /* INFOTABLE*/,

location: undefined /* LOCATION */,

source: undefined /* STRING */,

tags: undefined /* TAGS */

};

// result: STRING

var id = Things["SpeedDTDemo"].AddDataTableEntry(params);

If you are simply testing the service you will not see all the data that has been inserted previous to that particular call, for that you either need to navigate to your Datatable > HomeMashup, like i have shown below in the screenshot, or else you have to query your datatable to see the values that has been inserted so far

Hope this helps.

Announcements

Thingworx Navigate content has a new home! Click here to access the new Thingworx Navigate forum!