cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can change your system assigned username to something more personal in your community settings. X

Set value of property from RemoteThing

LR_11305480
3-Visitor

Set value of property from RemoteThing

I have a Thing with some properties from RemoteThings.

The type of the 'IndustrialThing' property is Thing.

LR_11305480_0-1720011726447.png

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);

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Rocko
17-Peridot
(To:LR_11305480)

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.

View solution in original post

3 REPLIES 3

HI @LR_11305480 

 

Try below code :

 

Things["THINGNAME"].PROPERTYNAME = "PROPERTYVALUE";

 

/VR

Rocko
17-Peridot
(To:LR_11305480)

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.

Thank you very much, Rocko!

That was exactly the problem with my code.

Top Tags