Skip to main content
16-Pearl
January 28, 2020
Solved

Iterate Datatable

  • January 28, 2020
  • 1 reply
  • 4186 views

Hi ,

I have Datatable with some records. I want to get the specific rows or field values by using Timestamp, and later I have to send the result through the mail. how we can get it? can someone has done it?  I am expecting pseudo code in javascript using datatable.

 

Thank you

Best answer by VaibhavShinde

yes, got it now , major query resolved!! now I am looking for filter data by avoiding time in timestamp. It should work with matching only Date without time. how can we filter timestamp field?

 

thanks

1 reply

16-Pearl
January 28, 2020

i think you need to create datatable with datashape having one datetime field as primary key.

store data to this datatable using service adddatatableentries.

 

now fetch the data from this datatable using getdatatableentrybykey ( where key is your timestamp field)

this will return one row in form of infotable. then you use infotable functions primarily for loop to iterate through infotable , get the values and store it in variables.

later you can send those values in email using sendmessage or other services from your mail server thing.

16-Pearl
January 28, 2020

Hello rosharma,

first of all thank you for quick response, I have already mahineKey as Primary key and suppose I want to get last week report by using timestamp field of Datatable. how we can do it ? by using query? by using any javascript code? 

Thank you 

16-Pearl
January 28, 2020

i think you can use QueryDatatableEntries on datatable passing in query parameter using "Between" keyword to generate the data specific to users inputs.

query would be like 

 

var query = 
{
 "filters": {
 "type": "Between",
 "fieldName": "Duration",
 "from": "2",
 "to": "12"
 }
};

And more on query parameter you can refer thingworx help center link 

https://support.ptc.com/help/thingworx_hc/thingworx_8_hc/en/index.html#page/ThingWorx/Help/Composer/Things/ThingServices/QueryParameterforQueryServices.html