Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X
Hi there
I've tried everything I could think of but I could not correctly call the UpdatePropertyValues function.
What Infotable is it waiting for ?
I need it for updating logged properties simultaneously, to not create a new log for each one.
if you have another solution for this problem, i'll gladly hear it, but I'd like an answer to the question because it has been bothering me for months.
Thank you.
Solved! Go to Solution.
Hi,
Here is how I use this service:
var params = {
infoTableName: "UpdatePropertiesInfoTableTMP" /* STRING */,
dataShapeName: "NamedVTQ" /* DATASHAPENAME */
};
var updateValues = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
var time = new Date();
updateValues.AddRow({'time': time, 'name': 'Property1Name', 'quality': 'GOOD', 'value': property1Value});
updateValues.AddRow({'time': time, 'name': 'Property2Name', 'quality': 'GOOD', 'value': property2Value});
...
me.UpdatePropertyValues({values: updateValues});
Francky,
How are you calling the service?
James
In many different ways.
var params = {
values: undefined /* INFOTABLE */ <-------- THIS is the problem, I've tried to put everything I could think of (only and always Infotables though)
};
me.UpdatePropertyValues(params);
How are you getting the updated values into the infotable? Are you calling the REST API?
I tried :
- creating objects (name, value) and pushing them into the rows array of an empty JSON Infotable
- creating a single object with an attribute for each property to update and pushing it into the rows array of an empty JSON Infotable
- same as first two but with a JSON infotable with the datashape corresponding to my objects
- same as first two but with a "normal" infotable without shape
- same as above but with the AddRow() method
- with a "normal" Infotable but with the correct shape and both methods (AddRow() and rows.push())
Hi,
Here is how I use this service:
var params = {
infoTableName: "UpdatePropertiesInfoTableTMP" /* STRING */,
dataShapeName: "NamedVTQ" /* DATASHAPENAME */
};
var updateValues = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
var time = new Date();
updateValues.AddRow({'time': time, 'name': 'Property1Name', 'quality': 'GOOD', 'value': property1Value});
updateValues.AddRow({'time': time, 'name': 'Property2Name', 'quality': 'GOOD', 'value': property2Value});
...
me.UpdatePropertyValues({values: updateValues});
QD beat me to it! See below for my alternative (and verbose!) update call:
// Create a new blank infotable for passing into the 'update' service
var params = {
infoTableName: "MyUpdateTable" /* STRING */
};
// result: INFOTABLE
var myUpdate = Resources["InfoTableFunctions"].CreateInfoTable(params);
// add the name field to the datashape for the update table
// this will hold the name of the property to update
var nameField = new Object();
nameField.name = "name";
nameField.baseType = 'STRING';
myUpdate.AddField(nameField);
// add the value field to the datashape for the update table
// this will hold the value of the property to update
var valueField = new Object();
valueField.name = "value";
valueField.baseType = 'STRING';
myUpdate.AddField(valueField);
// add the row that contains the update for temperature
var updateRow = new Object();
updateRow.name = 'temperature'; // << your actual property name here
updateRow.value = 32.0 // << your new value for that property here
// add the temperature row new value to the infotable
myUpdate.AddRow(updateRow);
var params = {
values: myUpdate /* INFOTABLE */
};
// Finally, update my thing with the properties in the table
me.UpdatePropertyValues(params);
The problem with this method is that the "value" of "updateRow" must be of a type which could be converted to STRING.
I'll be damned, it works.
I don't understand what was my mistake. I didn't try like James, but tried something similar to what QD did, but with a custom datashape containing name and value as Strings and it didnt work.
I now tried with a dynamic DS (like James) and it worked (probably the only way I had not tried yet)
Thanks