Hi, I have few properties (inherited from my Thing template) in my Thing.
I want to update my Thing's inherited property through service.
I tried :
Things[thing].test = "Test Value"; //tried to update value of my test property
result =Things[thing].test; // to check i printed it as result,
This method is not working for me ...
Solved! Go to Solution.
Hi,
I resolved my problem .. The reason I was not able to update properties is I haven't enabled and restarted my thing after creating it from service. so, i used the below code before passing property values
// logic for creating thing //
Things[''YourThingName"].EnableThing(); //to enable thing
Things[''YourThingName"].RestartThing();//to restart thing
//logic for update property values///
Hope, This will help someone someday......
Hi Max, Actually I creating thing and updating its property in loop.
I am able to create thing with correct TP but not able to update property values, I using TWX 8.5
for your ref:
let dataFromCSV = Resources["CSVParserFunctions"].ReadCSVFile(params); // infotable
for (let x = 0; x < dataFromCSV.rows.length; x++) {
let thingName = "Test_sabharees.N.T";
thingName = thingName.replace("N", customernumber.toString());
try {
Resources["EntityServices"].CreateThing({
name: thingName /* STRING */ ,
description: undefined /* STRING */ ,
thingTemplateName: "test_template" /* THINGTEMPLATENAME */ ,
tags: 'test_sabharees_tag:test_sabharees'
});
Things[thingName].AccessToken = dataFromCSV.rows[x].AccessToken; // text
Things[thingName].APIPassword = encrypt(dataFromCSV.rows[x].APIPassword); //password
Things[thingName].APIScope = dataFromCSV.rows[x].APIScope; //text
Things[thingName].ClientID = dataFromCSV.rows[x].ClientID; //text
Things[thingName].APIUsername = dataFromCSV.rows[x].APIUsername; //text
Things[thingName].ClientSecret = encrypt(dataFromCSV.rows[x].ClientSecret); //password
Things[thingName].CustomerID = dataFromCSV.rows[x].CustomerID; //int
Things[thingName].HeaderAuthorization = encrypt(dataFromCSV.rows[x].HeaderAuthorization); //password
Things[thingName].RESTBaseURL = dataFromCSV.rows[x].RESTBaseURL; //text
result = true;
} catch (err) {
result = false + err.lineNumber + err;
logger.warn(" Service error in " + me.name + err.lineNumber + err);
Resources["EntityServices"].DeleteThing({
name: thingName /* THINGNAME */
});
}
}
} catch (err) {
result = false + err.lineNumber + err;
logger.warn("Service error in " + me.name + err.lineNumber + err);
}
function encrypt(value) {
return Resources["EncryptionServices"].EncryptPropertyValue({
data: value
});
}
Hi,
I resolved my problem .. The reason I was not able to update properties is I haven't enabled and restarted my thing after creating it from service. so, i used the below code before passing property values
// logic for creating thing //
Things[''YourThingName"].EnableThing(); //to enable thing
Things[''YourThingName"].RestartThing();//to restart thing
//logic for update property values///
Hope, This will help someone someday......