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

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

How to add property values of a thing to infotable in ThingWorx

Aditya1702
13-Aquamarine

How to add property values of a thing to infotable in ThingWorx

Hello,

 

I want to add property values of a thing to an infotable/datatable thing in ThingWorx,

For Eg: I have a datatable with a datashape having three columns(column 1, column 2, column 3)

also, I have 3 properties (column1Prop, column2Prop, column3Prop)

 

I want to add these properties as a Row to the datatable.

 

Can anyone help me please.

 

Thanks in advance.

 

Regards,

Aditya Gupta

1 ACCEPTED SOLUTION

Accepted Solutions
Rocko
17-Peridot
(To:Aditya1702)

Hi Aditya,

you would create a subscription to a DataChangeEvent that fires whenever one of those properties was changed.

in that subscription you would add a row to the dataTable. Roughly like this:

let v=DataShapes["TheDataShapeOfYourDataTable"].CreateValues();
v.AddRow({prop1:eventData.newValue.prop1, prop2:eventData.newValue.prop2, prop3:eventData.newValue.prop3);
me.AddDataTableEntry({values: v});

 

The question is though why you would not use Value Streams instead which are explicitly made for that use case. Just assign a value stream to the thing and set the three properties to "logged".

 

View solution in original post

9 REPLIES 9

Hi, @Aditya1702  Take a look at the below reference article.

https://www.ptc.com/en/support/article/CS277418

Hi @Surya_Tiwari ,

 

I am not able to understand this, I will just brief you once again what I want to achieve:

I have few properties which are changing, so everytime the value changes I want to add those property values into a datatable.

 

eg. I have property1, property2 & property3 so evertyime the value of these properties changes I want to record them into a datatable.

 

Do you have any solution for this?.

 

Thank You.

 

Regards,

Aditya Gupta

Rocko
17-Peridot
(To:Aditya1702)

Hi Aditya,

you would create a subscription to a DataChangeEvent that fires whenever one of those properties was changed.

in that subscription you would add a row to the dataTable. Roughly like this:

let v=DataShapes["TheDataShapeOfYourDataTable"].CreateValues();
v.AddRow({prop1:eventData.newValue.prop1, prop2:eventData.newValue.prop2, prop3:eventData.newValue.prop3);
me.AddDataTableEntry({values: v});

 

The question is though why you would not use Value Streams instead which are explicitly made for that use case. Just assign a value stream to the thing and set the three properties to "logged".

 

Aditya1702
13-Aquamarine
(To:Rocko)

Hello @Rocko ,

 

Thanks for your reply.

 

I am new to thingworx so, can you please provide me a step by step solution?

 

 

Rocko
17-Peridot
(To:Aditya1702)

Sounds good. Please do not forget to plan purging the value stream regularly to not overfill your database. You can read about it in the help and here: https://www.ptc.com/en/support/article/CS271772

I also recommend the ThingWorx Learning Paths to get started with ThingWorx: https://community.ptc.com/t5/IoT-Tips/ThingWorx-Learning-Paths/ta-p/841623

Aditya1702
13-Aquamarine
(To:Rocko)

Hi @Rocko ,

Good Morning,

 

What if I want to move this stored data to some other database or any storage for my future reference

then how do I go about it?

 

Thanks in Advance.

Rocko
17-Peridot
(To:Aditya1702)

Aditya1702
13-Aquamarine
(To:Rocko)

Okay. 

I will surely try & let you know if any issues.

 

Thank You.

 

Regards,

Aditya Gupta

Aditya1702
13-Aquamarine
(To:Rocko)

Hi @Rocko ,

Good Morning,

 

Value Stream did worked for me.

I set the properties to be logged & then executed QueryPropertyHistory Service.

Hope this is the right way.

 

Thanks & Regards,

Aditya Gupta

Top Tags