Solved
UpdatePropertyValues not working
Hi,
I’m currently using Thingworx 9.3.9 and facing an issue while trying to update the property values of boolean properties in a Thing. I’m using the UpdatePropertyValue default service for this purpose.
However, the service is not allowing me to update the values for the current time. When I try to update the values for current time minus 2 or 4 minutes, it works, but not consistently.
Note: The DataChangeType for these properties is set to value.
Method 1: I am using a dynamic DataShape for updating the property values via UpdatePropertyValue.
------------------------------------------------------------------------------------------------------
var currentTime = new Date();
currentTime.setMinutes(currentTime.getMinutes() - 2);
var DataShapeparams = {
infoTableName: "MyUpdateTable" /* STRING */
};
var UpdateEntryIT = Resources["InfoTableFunctions"].CreateInfoTable(DataShapeparams);
var nameField = new Object();
nameField.name = 'name';
nameField.baseType = 'STRING';
UpdateEntryIT.AddField(nameField);
var valueField = new Object();
valueField.name = "value";
valueField.baseType = 'BOOLEAN';
UpdateEntryIT.AddField(valueField);
var dateField = new Object();
dateField.name = "time";
dateField.baseType = 'DATETIME';
UpdateEntryIT.AddField(dateField);
var qualityField = new Object();
qualityField.name = "quality";
qualityField.baseType = 'STRING';
UpdateEntryIT.AddField(qualityField);
var updateRow = new Object();
updateRow.name = Propertyname; // << your actual property name here
updateRow.value = true;// << your new value for that property here
updateRow.time = currentTime;
updateRow.quality = 'GOOD';
UpdateEntryIT.AddRow(updateRow);
Things[Thingname].UpdatePropertyValues({
values: UpdateEntryIT /* INFOTABLE {"dataShape":"NamedVTQ"} */
});
-----------------------------------------------------------------------------
Method 2 - using NamedVTQ datashape (static datashape)
let newEntry = {
name: Propertyname, // STRING [Primary Key]
time: currentTime, // DATETIME
value: false,//Things[Thingname][Propertyname], // VARIANT
quality: undefined // STRING
};
UpdateEntryIT.AddRow(newEntry);
Things[Thingname].UpdatePropertyValues({
values: UpdateEntryIT /* INFOTABLE {"dataShape":"NamedVTQ"} */
});

