Solved
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"} */
});
Lots of conditions!
First would query without a startdate and maxItems=2, oldestfirst=false. Enddate would be 7AM. This will give you at least two rows, always. Then you check if the first row has a date of exactly 07:00:00:000 (unlikely, but possible) and if so you duplicate the value with a new timestamp.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.

