Hi @vi1 ,
I tested in TWX 9.1.3 and 9.3.2 with below code and it seems I could pass default value with Infotable Type data to AddPropertyDefinition service successfully and the property created at ThingShape level with default value set without any issue.
// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(WeatherDataShape)
let a = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape({
infoTableName: "InfoTable",
dataShapeName: "WeatherDataShape"
});
// WeatherDataShape entry object
let newEntry = {
id: 1,// NUMBER [Primary Key]
date: undefined,// DATETIME
max_temp: 33,// NUMBER
min_temp: 22,// NUMBER
cold: undefined,// BOOLEAN
visibility: undefined,// INTEGER
wind: undefined,// LONG
events: undefined,// STRING
image: undefined,// IMAGELINK
location: undefined,// LOCATION
actions: undefined,// HTML
info: undefined// HYPERLINK
};
a.AddRow(newEntry);
ThingShapes["testThingShape"].AddPropertyDefinition({
defaultValue: a /* STRING */,
remoteBindingAspects: undefined /* JSON */,
description: undefined /* STRING */,
readOnly: undefined /* BOOLEAN */,
type: "INFOTABLE" /* BASETYPENAME */,
remote: undefined /* BOOLEAN */,
remotePropertyName: undefined /* STRING */,
timeout: undefined /* INTEGER */,
pushType: undefined /* STRING */,
dataChangeThreshold: undefined /* NUMBER */,
logged: undefined /* BOOLEAN */,
name: "test2" /* STRING */,
pushThreshold: undefined /* NUMBER */,
dataChangeType: undefined /* STRING */,
category: undefined /* STRING */,
persistent: true /* BOOLEAN */,
dataShape: "WeatherDataShape" /* DATASHAPENAME */
});
The only problem is that the service requires the same property name does not exist in advance. It cannot update existing property and set a default value to it.
Another workaround I guess is to use ThingShapes["xxx"].GetImplementingThings(); to get a list of instantiated things, loop through the entity list and update property values - this should have the same effect as setting default value at ThingShape level.
Hope that helps.