cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Assigning data shape and thing shape to data table only assigns the data shape not thing shape.

avkumar15
4-Participant

Assigning data shape and thing shape to data table only assigns the data shape not thing shape.

// 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();

 

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

1 REPLY 1

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

View solution in original post

Announcements