Skip to main content
5-Regular Member
July 19, 2018
Question

how to change data change type against a particular property through a service

  • July 19, 2018
  • 1 reply
  • 971 views

how to change "data change type" value against a particular property through a service

1 reply

1-Visitor
July 20, 2018

Hello,

I guess there is no possibility of changing the type of the property at runtime using service. But what I can propose is, write a custom service where - 

STEP 1: Get the attributes (name, base type, description, logged, persistence, read-only etc.) of your property using the generic service 'GetPropertyDefinition' and store them locally in the service.

STEP 2: Delete the property for which you need to change the data (base) type using another generic service 'RemovePropertyDefinition'

STEP 3: Create another property, using the attributes we saved in STEP 1, keeping everything same and just changing the data (base) type. To do so you can use a generic service 'AddPropertyDefinition'. Possibly use try-catch when creating the property. Restart the thing, its a mandatory step, at the end. This will add the property to your thing dynamically.

I hope it helps. But I am wondering why would you want to do so, because in programming we don't change the data type of the variable at run time. If there is a possibility to use the type-casting feature, I would suggest, try to evaluate and use that.

Thanks

Aditya