Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X
Good morning!
I have created a few Things which inherit the properties from a ThingTemplate which holds a property Identifier string and another property for temperature.
In addition, I have created a helper thing to create a static service. This service gets two inputs: an identifier string and the temperature.
The service should retrieve the name of the thing which holds the same identifier string and should update the temperature property.
I have already found a function which seems to be made for that. It is called GetThingNameForIdentifier(identifier) and returns a THINGNAME.
But I haven't found anything on the internet on how to use this datatype and how to access the thing's properties.
Any suggestions?
Thank you in advance for your help
Theresa~
Solved! Go to Solution.
Please try:
Things[THINGNAME].temperature= temperature;
hi Ankit Gupta,
and how do I use the GetThingnameByIdentifier(identifier) function?
Is it like this or am I doing anything wrong:
var params = {
identifier: ID/* STRING: ID is the property Name of the Thing */
};
// result: THINGNAME
var thingname = Resources["EntityServices"].GetThingNameForIdentifier(params);
Things[thingname].temperature= temperature;
thank you again for your help!
because if I test my service I get a the following error:
TypeError: Cannot set property "temperature" of null to "40"
Are you entering the identifier name in ID input? i.e. TestName for below example
thank you!
I now have defined identifiers. I first thought to take the self-defined identifier property of the thing (is this even possible?).
There is no built-in service to find the Thing based on the custom property values.
We will have to create our custom service for that.
There could be a better way; here is what I would try:
1. Get list of all entities of type Thing.
2. Loop through the Things and get property Definition to find out which thing has my custom property.
3. If the Thing has the Custom Property; compare its value.
The service can be improved if we have more specific details about the Thing.
I hope it helps.
The service is correct. It works fine for me.
Please recheck that you are entering correct identifier for the Thing in input ID.
Adding to what Ankit already said, you can check the default BaseTypes for ThingWorx via the API Documentation