Set value of property from RemoteThing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Set value of property from RemoteThing
I have a Thing with some properties from RemoteThings.
The type of the 'IndustrialThing' property is Thing.
Manually, I can set the value to 'ANOTHERTHING' if I want to, but I want to set it through a service using code.
I've tried the code below, it gives no errors, but it doesn't work.
var params = {
propertyName: 'IndustrialThing',
propertyValue: 'ANOTHERTHING'
};
Things['MYTHING'].SetPropertyValues(params);
Solved! Go to Solution.
- Labels:
-
Coding
-
Troubleshooting
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
The issue is most probably that SetPropertyValues (notice the plural for setting multiple values) expects you to provide an infotable for all the properties and values you want to set. The code you provided just passes over a simple object.
The valid code would be something along this:
let t = Resources["InfoTableFunctions"].CreateInfoTable();
t.AddField({name: "IndustrialThing", baseType: 'THINGNAME'});
t.AddRow({IndustrialThing:"ANOTHERTHING"});
Things["MYTHING"].SetPropertyValues({values: t});
Maybe Velkumar's suggestion is the better way to go.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
The issue is most probably that SetPropertyValues (notice the plural for setting multiple values) expects you to provide an infotable for all the properties and values you want to set. The code you provided just passes over a simple object.
The valid code would be something along this:
let t = Resources["InfoTableFunctions"].CreateInfoTable();
t.AddField({name: "IndustrialThing", baseType: 'THINGNAME'});
t.AddRow({IndustrialThing:"ANOTHERTHING"});
Things["MYTHING"].SetPropertyValues({values: t});
Maybe Velkumar's suggestion is the better way to go.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thank you very much, Rocko!
That was exactly the problem with my code.
