I need to add couple of new properties to my Things at run-time. To achieve this I have tried using "AddPropertyDefinition" service from my composer environment. I am using ThingWorx 8.1.0. I sought references from various topics like -
As mentioned in one of the links that it is needed to restart the Thing, I tried doing that, but doesn't work for me.
The execution of this service does not return any error, but does not give the expected output as well.
I tried to also use this service using "Test Service" button against the same service listed under generic services for a Thing.
Any possible reasons for the same?
Solved! Go to Solution.
I am not doing it by any custom service, I am first trying to add the property using the "Test" service option (attached screen shot for reference) for a Thing (based on generic Thing template). I have filled in the required values like name, basetype and description. Service execution seems successful (as there is no exception or error). But still the property is not added in my thing.
Please let me know in case any other information is required from my end to better understand the issue.
YES..Its working now!!!. I did a custom service, and called re-start thing and the property was added. It worked.
Thanks a lot for your support and suggestion.
I will also assume that in case I need to add multiple properties, I will add them first all at once, using "AddPropertyDefinition", and then after adding the properties I need, I will do a restart thing once to have them all added my thing.
But it was surprising it did not work using the Test option, and I actually, as suggested, did a restart thing by enabling and disabling the thing and saving it. I thought that step is synonymous to restart thing (as thingStart event is fired after this step).
But anyways, restart thing service made it work. I'll accept it as solution.
There's a big difference between Test on Composer and a Service as a whole --> The transaction, on the Service as a whole you do on the same transaction the Add Property and Restart, with Test on Composer you do different transactions ;)
Yes, to add multiple properties, first add them all an then restart.
Thanks for that. To understand some more, the provision for setting up remote binding option(s) in the service AddPropertyDefinition is similar to what is achieved by calling the service "SetRemotePropertyBinding", is that right? But we don't have a provision to do what is achieved by "SetLocalPropertyBinding".
So if I have to set local property binding, I have to add the properties to my thing, restart the thing and do the local property binding activity for those properties probably in the thingstart event subscription (as it would be fired, once the thing restarts after adding the properties) right..?
I definitely cannot do "SetLocalPropertyBinding", just after calling the custom service to create the properties, as the stack context would be lost after restart thing. Right??
I hope I am able to express, what I am trying to do, properly in writing. But please let me know if you need any further clarification.
If there are multiple properties to add to a thing, one option as we discussed in this post is to use the service "AddPropertyDefinition" in a loop, but I can see there is also a service "AddPropertyDefinitions". It accepts an Infotable and a bool type parameter, but I am not sure, what datashape that infotable shall be? Should that Infotable be of type 'PropertyDefination' datashape? I am not able to find required infomation/documnetation to use that service. Any help would be appreciated.