Skip to main content
1-Visitor
April 22, 2020
Solved

Unable to execute service GetThingRelationships on ThingTemplate

  • April 22, 2020
  • 1 reply
  • 1100 views

Hi,

 

I am trying out few operations on templates via java sdk. One of the use case is getting all the thing names that are derived from a particular template. According to the documentation, a simple invokeService call to GetThingRelationships should get this done cleanly. The service expects an input of maxDepth we want to keep searching the things. (e.g. vehicalTemplate -> CarTemplate -> ElectricCarTemplate -> TeslaCar1Thing, TeslaCar2Thing, TeslaCar3Thing etc ).

 

When tried to execute the call via java sdk - 

client.invokeService(RelationshipTypes.ThingworxEntityTypes.ThingTemplates, "templateName", "GetThingRelationships", new ValueCollection(), 30000)

 throws exception stating - Invalid service name.

 

Same goes for other services like - GetImpletementedShapes, GetThingTemplate etc. 

Are these not the valid services for  entityType templates? If so, why are they listed under Services section of my template in composer UI?

 

I am using ThingWorx 8.5, if it is version related issue. 

 

Any help is very much appreciated!

 

Regards,

Vaishnavee

Best answer by tmisner

Hello Vaishnavee,

 

Looking at GetThingRelationships, this is a Thing service call to be executed at the Thing level. It cannot be executed at the Thing Template level. It along with the other services you described are displayed at the Thing Template level as they are intended to be passed on to the inheriting Things and executed there.

 

There are however some specific services that will help you achieve your use case. At the Thing Template level you can call either GetImplementingThings or GetImplementingThingsWithData depending on the return you are after. GetImplementingThingsWithData simply adds an extra column for the Thing's direct Thing Template.

1 reply

tmisner16-PearlAnswer
16-Pearl
April 22, 2020

Hello Vaishnavee,

 

Looking at GetThingRelationships, this is a Thing service call to be executed at the Thing level. It cannot be executed at the Thing Template level. It along with the other services you described are displayed at the Thing Template level as they are intended to be passed on to the inheriting Things and executed there.

 

There are however some specific services that will help you achieve your use case. At the Thing Template level you can call either GetImplementingThings or GetImplementingThingsWithData depending on the return you are after. GetImplementingThingsWithData simply adds an extra column for the Thing's direct Thing Template.

1-Visitor
April 23, 2020

Thank you @tmisner for the solution. The service GetImplementingThings was exactly what I was looking for!