I have a service that is making a REST API call to our platform, and then generates a bunch of Things with the response data. My current setup is to call the service from a Thing Template. My problem is that after creating the Things I need to add custom property definitions, which I can't always anticipate ahead of time. I don't see a "target existing Thing" snippet anywhere; is there a way I can add properties to the Things after they've been created, from the Template's service?
You will need to access the AddPropertyDefinition service of the Thing you created.
You can refer to the thing you just created by simply saying Things["ThingName"].ServiceName(params)
The params for AddPropertyDefinition you can find by accessing Entities tab (from Service definition window) and then adding this method from an existing Thing.
Note: I didn't try, but you might need to restart the thing afterwards in order to make the property available for READ/WRITE from other services.
Hope it helps,
I see! Okay, I can now add properties to the things from the service.
As for any Thing Property, for the setting the value of the property you can simply call Things["ThingName"].PropertyName = yourValue
Just as a side idea I think it would be a great help to check the very helpful videos on the Suport/Video tutorials tab (I know they helped me a lot!). There is a trick there, the videos you see when entering the Video Tutorial page are only a small subset from the available videos. To display them all, delete ThingWorx from the Search box, then press Search. Now wait some seconds (5-10) and you will see that the right video list scrollbar becomes very small and you will be able to scroll through a much, much larger Videos collection.