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

Community Tip - You can change your system assigned username to something more personal in your community settings. X

how to listen a thing property value change ?

YC_10946483
6-Contributor

how to listen a thing property value change ?

hello,can i please ask how to listen on a thing property value change and coding in this thing service  to save new value  to db?

ACCEPTED SOLUTION

Accepted Solutions

You would use a thing subscription for this. There is a tab called subscription in the Thing View in Composer. You can add a subscription there listening to the DataChange Event of a property of a thing. In the subscription, you can write code to perform, or call another service. Note the subscription has to be active to execute.

The property value is automatically saved to the DB, if the property has the "persist" flag. If you also want to record previous entries, you need to set the "log" flag on the property and provide a value stream in the thing configuration (on tab General Information).

 

If you want to write the value additionally to an external DB, you can run a SQL Command service from a DatabaseThing to do the INSERT in your subscription.

 

References:

https://community.ptc.com/t5/IoT-Tips/Thing-Subscription/ta-p/817695

https://community.ptc.com/t5/IoT-Tips/Implement-Services-Events-and-Subscriptions-Guide-Part-1/ta-p/837216#toc-hId-1134107572

https://support.ptc.com/help/thingworx/platform/r9/en/#page/ThingWorx/Help/ModelandDataBestPractices/UsingJDBCasthePersistenceProvider.html

 

View solution in original post

2 REPLIES 2

You would use a thing subscription for this. There is a tab called subscription in the Thing View in Composer. You can add a subscription there listening to the DataChange Event of a property of a thing. In the subscription, you can write code to perform, or call another service. Note the subscription has to be active to execute.

The property value is automatically saved to the DB, if the property has the "persist" flag. If you also want to record previous entries, you need to set the "log" flag on the property and provide a value stream in the thing configuration (on tab General Information).

 

If you want to write the value additionally to an external DB, you can run a SQL Command service from a DatabaseThing to do the INSERT in your subscription.

 

References:

https://community.ptc.com/t5/IoT-Tips/Thing-Subscription/ta-p/817695

https://community.ptc.com/t5/IoT-Tips/Implement-Services-Events-and-Subscriptions-Guide-Part-1/ta-p/837216#toc-hId-1134107572

https://support.ptc.com/help/thingworx/platform/r9/en/#page/ThingWorx/Help/ModelandDataBestPractices/UsingJDBCasthePersistenceProvider.html

 

YC_10946483
6-Contributor
(To:Rocko)

ok,thank you!

Announcements


Top Tags