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

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

How to get implemented shapes from a thing shape without knowing a thing name

JK_10744682
6-Contributor

How to get implemented shapes from a thing shape without knowing a thing name

Hi,

 

I am trying to get the implemented shapes for a thing template. I do not have a thing created yet using this template but want to be able to call this GetImplementedShapes() service but just for the template not for a thing. Any ideas on if it is possible to get the shapes implemented on just the shape itself?

ACCEPTED SOLUTION

Accepted Solutions

@JK_10744682  Sorry I didn't get your requirement properly

 

From ThingTemplate, if you want to get the list of implemented ThingShape in ThingTemplate. You can use the below code

// result: INFOTABLE dataShape: "EntityDescriptor"
let data = ThingTemplates["TEMPLATENAME"].GetOutgoingDependencies({
	maxItems: undefined /* NUMBER {"defaultValue":500} */
});

let query = {
	"filters": {
		"type": "EQ",
		"fieldName": "type",
		"value": "ThingShape"
	}
};

let params = {
	t: data /* INFOTABLE */ ,
	query: query /* QUERY */
};

// result: INFOTABLE
let result = Resources["InfoTableFunctions"].Query(params);

 

From ThingShape, if you want to get the list of ThingTemplate using ThingShape

// Provide your filter using the format as described in the help topic "Query Parameter for Query Services"
let query = {
 "filters": {
   "type": "EQ",
   "fieldName": "entityType",
   "value": "ThingTemplate"
 }
};

// result: INFOTABLE dataShape: "RootEntityList"
let relationshipData = ThingShapes["SHAPENAME"].GetWhereUsed();


let params = {
	t: relationshipData /* INFOTABLE */,
	query: query /* QUERY */
};

// result: INFOTABLE
let result = Resources["InfoTableFunctions"].Query(params);

 

/VR

View solution in original post

5 REPLIES 5

Hi @JK_10744682 

 

You can use the below code to get implemented Thing Names

 

// result: INFOTABLE dataShape: "RootEntityList"
let result = ThingShapes["SHAPENAME"].GetImplementingThings();

 

/VR

JK_10744682
6-Contributor
(To:Velkumar)

This isn't exactly what I want. I need to be able to get the implemented thing shapes that are on a thing template, but calling GetImplementedShapes() requires a thing name (but I just want the shapes on the template, not a thing)

Hi @JK_10744682 

 

I don't think we have a direct method to get the implemented thing template list.

 

You can use GetWhereUsed service to get relationship information - Using the GetWhereUsed Service (ptc.com)

 

Sample Code

 

// Provide your filter using the format as described in the help topic "Query Parameter for Query Services"
let query = {
 "filters": {
   "type": "EQ",
   "fieldName": "entityType",
   "value": "ThingTemplate"
 }
};

// result: INFOTABLE dataShape: "RootEntityList"
let relationshipData = ThingShapes["SHAPENAME"].GetWhereUsed();


let params = {
	t: relationshipData /* INFOTABLE */,
	query: query /* QUERY */
};

// result: INFOTABLE
let result = Resources["InfoTableFunctions"].Query(params);


 

 

Output :

 

Velkumar_0-1721408036479.png

 

 

/VR

JK_10744682
6-Contributor
(To:Velkumar)

I see. I really just need a way to get a list of the shapes that are on a template if there is any way to do that.

@JK_10744682  Sorry I didn't get your requirement properly

 

From ThingTemplate, if you want to get the list of implemented ThingShape in ThingTemplate. You can use the below code

// result: INFOTABLE dataShape: "EntityDescriptor"
let data = ThingTemplates["TEMPLATENAME"].GetOutgoingDependencies({
	maxItems: undefined /* NUMBER {"defaultValue":500} */
});

let query = {
	"filters": {
		"type": "EQ",
		"fieldName": "type",
		"value": "ThingShape"
	}
};

let params = {
	t: data /* INFOTABLE */ ,
	query: query /* QUERY */
};

// result: INFOTABLE
let result = Resources["InfoTableFunctions"].Query(params);

 

From ThingShape, if you want to get the list of ThingTemplate using ThingShape

// Provide your filter using the format as described in the help topic "Query Parameter for Query Services"
let query = {
 "filters": {
   "type": "EQ",
   "fieldName": "entityType",
   "value": "ThingTemplate"
 }
};

// result: INFOTABLE dataShape: "RootEntityList"
let relationshipData = ThingShapes["SHAPENAME"].GetWhereUsed();


let params = {
	t: relationshipData /* INFOTABLE */,
	query: query /* QUERY */
};

// result: INFOTABLE
let result = Resources["InfoTableFunctions"].Query(params);

 

/VR

Announcements


Top Tags