Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
// creating data table
var createResult = Things[thingname].customCreateEntity({
templateName: "DataTable" /* THINGTEMPLATENAME */,
entityName: dtName /* STRING */,
description: dtDesc /* STRING */,
tags: undefined /* TAGS */
});
Things[dtName].EnableThing();
Things[dtName].RestartThing();
//Now set the Datashape for this DT
Things[dtName].SetDataShape({ name: dataShape });
Things[dtName].EnableThing();
Things[dtName].RestartThing();
// Assign thingshape to this DT
Resources["EntityServices"].AddShapeToThing({
name: dtName /* THINGNAME */,
thingShapeName: customThingShape /* THINGSHAPENAME */
});
Things[dtName].EnableThing();
Things[dtName].RestartThing();
Solved! Go to Solution.
Hello @avkumar15
I tried same code, it works fine in my environment. PFB code
try {
var params = {
name: "Test_DataTable" /* STRING */ ,
description: undefined /* STRING */ ,
thingTemplateName: "DataTable" /* THINGTEMPLATENAME */ ,
tags: undefined /* TAGS */
};
// no return
Resources["EntityServices"].CreateThing(params);
Things["Test_DataTable"].SetDataShape({
name: "NamedVTQ" /* DATASHAPENAME */
});
var params = {
name: "Test_DataTable" /* THINGNAME */ ,
thingShapeName: "PTC.Asset.Session" /* THINGSHAPENAME */
};
// no return
Resources["EntityServices"].AddShapeToThing(params);
Things['Test_DataTable'].EnableThing();
Things['Test_DataTable'].RestartThing();
} catch (err) {
var params = {
name: "Test_DataTable" /* THINGNAME */
};
// no return
Resources["EntityServices"].DeleteThing(params);
}
/VR
Hello @avkumar15
I tried same code, it works fine in my environment. PFB code
try {
var params = {
name: "Test_DataTable" /* STRING */ ,
description: undefined /* STRING */ ,
thingTemplateName: "DataTable" /* THINGTEMPLATENAME */ ,
tags: undefined /* TAGS */
};
// no return
Resources["EntityServices"].CreateThing(params);
Things["Test_DataTable"].SetDataShape({
name: "NamedVTQ" /* DATASHAPENAME */
});
var params = {
name: "Test_DataTable" /* THINGNAME */ ,
thingShapeName: "PTC.Asset.Session" /* THINGSHAPENAME */
};
// no return
Resources["EntityServices"].AddShapeToThing(params);
Things['Test_DataTable'].EnableThing();
Things['Test_DataTable'].RestartThing();
} catch (err) {
var params = {
name: "Test_DataTable" /* THINGNAME */
};
// no return
Resources["EntityServices"].DeleteThing(params);
}
/VR