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

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

How create sequence from Data Tables?

shlee
3-Visitor

How create sequence from Data Tables?

I starting to study thingworx

I want create increase sequence to number in Thingworx Data Tables

I made Data Tables after made Data Shapes and Fields

I made Field of Five in the Fields so want to input sequence values ​​into the Num Field

How create sequence from Data Tables?

I want simple source code if made from services or let me know if you have other way

1 ACCEPTED SOLUTION

Accepted Solutions
AnnaAn
13-Aquamarine
(To:shlee)

Hi SANG HYUN LEE​,

Just share with you what I did to create sequence ID for data table.

1. create a new Property named "ID" with NUMBER basetype under my Data Table

2. In the Service where I add a new DataTable Entry

var values = me.CreateValues();

values.sourceType = undefined; //STRING
values.location = undefined; //LOCATION
values.source = undefined; //STRING
values.key = me.ID; //STRING [Primary Key]
values.timestamp = undefined; //DATETIME
values.tags = undefined; //TAGS

var params = {
sourceType: undefined /* STRING */,
values: values /* INFOTABLE*/,
location: undefined /* LOCATION */,
source: undefined /* STRING */,
tags: undefined /* TAGS */
};
me.ID=values.key+1;
// result: STRING
var result = me.AddDataTableEntry(params);

Hope this helps,

Br,

Anna

View solution in original post

2 REPLIES 2
AnnaAn
13-Aquamarine
(To:shlee)

Hi SANG HYUN LEE​,

Just share with you what I did to create sequence ID for data table.

1. create a new Property named "ID" with NUMBER basetype under my Data Table

2. In the Service where I add a new DataTable Entry

var values = me.CreateValues();

values.sourceType = undefined; //STRING
values.location = undefined; //LOCATION
values.source = undefined; //STRING
values.key = me.ID; //STRING [Primary Key]
values.timestamp = undefined; //DATETIME
values.tags = undefined; //TAGS

var params = {
sourceType: undefined /* STRING */,
values: values /* INFOTABLE*/,
location: undefined /* LOCATION */,
source: undefined /* STRING */,
tags: undefined /* TAGS */
};
me.ID=values.key+1;
// result: STRING
var result = me.AddDataTableEntry(params);

Hope this helps,

Br,

Anna

shlee
3-Visitor
(To:AnnaAn)

Thank you

I  well used the Simple code

Top Tags