Skip to main content
1-Visitor
March 28, 2018
Question

Get List of all Thing Templates

  • March 28, 2018
  • 3 replies
  • 3029 views

Hello Everyone,

 

i am struggling with finding out how to get a list of all ThingTemplates (or at least their names) in the TWx Platform. Optionally it would be nice to filter these on "has things that implement template" and "does not have things that implement template".

 

In the Platform API Documentation i found a method on ThingTemplates:

 

getAllImplementedThingTemplates() -> returns an EntityReferenceCollection

 

But i don't know how to invoke this service properly (e.g What is the name of the Entity this service is invoked on?) 

 

Any help is appreciated very much.

 

Regards,

Dominik

    3 replies

    22-Sapphire I
    March 28, 2018

    You are probably better off using the SearchFunctions resource, there is a SearchEntities or SpotlightSearch and you can set the type to ThingTemplate. parameter call out would be: types: {items: ["ThingTemplate"]}

    In the UI you can use the Entity Picker

    drieder1-VisitorAuthor
    1-Visitor
    March 29, 2018

    Thank you, this indeed lists all Templates (even System Objects). 

     

    Any Idea how to filter these Properly? The results of a search call have an attribute called "isSystemObject", but i wasn't able to write an expression neither in the "excluded aspects" nor in the "searchExpression" parameter field for the search function (using SpotlightSearch btw).

     

    Something like: show only if isSystemObject == false.

     

    Thanks for your collaboration!

     

    Regards,

    Dominik

    22-Sapphire I
    March 29, 2018

    You can try the search expression but it won't be reliable because it does a text search.

    However after you get the search result it is an infotable and you can do a .Query

    In the Thingworx help do a search for Search Parameters to find out how to build proper queries.