Skip to main content
1-Visitor
August 25, 2022
Solved

Log data only when wanted

  • August 25, 2022
  • 1 reply
  • 802 views

Hello,

 

I am sending data to my Things. Those data are in an infotable like this:

AF_10328563_0-1661416190708.png

my lastSession json looks like this: 

AF_10328563_1-1661416362360.png

 

However, sometimes I will send the same data but my lastSession will change but keep the same ID.
I want to log all my data. However, when a lastSession comes with the same ID as the old one, I want to replace the data and not log them.

I tried to PurgeSelectedPropertyHistory but it did not work.

 

Does anyone have an idea ?

 

Best answer by nmilleson

If you need to log with custom logic, I would suggest turning off the "logged" attribute on your Thing Property and writing a custom subscription that triggers on data change of that property.  Then you can decide whether to log that value to a stream or change the stream entry in place.  Keep in mind that this may force you to use Streams instead of the ValueStream since ValueStream entries cannot be modified (per https://community.ptc.com/t5/ThingWorx-Developers/Modifying-stream-entries/td-p/624867).

 

-Nick

1 reply

nmilleson17-PeridotAnswer
17-Peridot
August 26, 2022

If you need to log with custom logic, I would suggest turning off the "logged" attribute on your Thing Property and writing a custom subscription that triggers on data change of that property.  Then you can decide whether to log that value to a stream or change the stream entry in place.  Keep in mind that this may force you to use Streams instead of the ValueStream since ValueStream entries cannot be modified (per https://community.ptc.com/t5/ThingWorx-Developers/Modifying-stream-entries/td-p/624867).

 

-Nick