Skip to main content
16-Pearl
March 15, 2024
Solved

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

  • March 15, 2024
  • 1 reply
  • 3522 views

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

Best answer by Rocko

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".

 

1 reply

16-Pearl
March 15, 2024

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

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

16-Pearl
March 15, 2024

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
Rocko19-TanzaniteAnswer
19-Tanzanite
March 15, 2024

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".