Skip to main content
1-Visitor
Jul 7, 2017 4:07 AM UTC
Solved

How to search Things by name?

I have several Things named "thing1", "thing2", "thing3", "thing4", etc, which I want to delete. I am thinking of a way to first 'Find' or 'Query' or 'Search' the Things that begins with "thing" and then 'Delete' them. Nevertheless, I do not know which service to use to 'Find' or 'Query' or 'Search' Things.


Anybody knows what service do I need? Or is there any better solution to my intention?


thanks

supandeyAnswer
5-Regular Member
Jul 7, 2017 1:34 PM UTC

You can try this, i think this fits your requirement more

var params = {

  maxItems: 500 /* NUMBER */,

  nameMask: "<provide entity name here>" /* STRING */,

  type: 'Thing' /* STRING */,

  tags: undefined /* TAGS */

};

// result: INFOTABLE dataShape: RootEntityList

var result = Resources["EntityServices"].GetEntityList(params);

Note that you can use the Type to seach for different entities like Things, Mashups, Users etc

You can find this together with other EntityServices under the Snippets > EntityServices

5 replies

5-Regular Member
Jul 7, 2017 7:00 AM UTC

Hi Samuel, you can consider using one of the following search functions available directly under the ThingWorx Composer > System > Resources > SearchFunctions

Hope this helps.

Translate
syu11-VisitorAuthor
1-Visitor
Jul 7, 2017 8:48 AM UTC

Hi Sushant, thank you for your reply! Could you, please, be more specific about what Inputs I should enter in order to search the Things I need? I took a look at the Inputs of these three services but just couldn't find 'names' in them. Does that mean I can't search things by name? Or are there other ways to try?

Translate
supandey5-Regular MemberAnswer
5-Regular Member
Jul 7, 2017 1:34 PM UTC

You can try this, i think this fits your requirement more

var params = {

  maxItems: 500 /* NUMBER */,

  nameMask: "<provide entity name here>" /* STRING */,

  type: 'Thing' /* STRING */,

  tags: undefined /* TAGS */

};

// result: INFOTABLE dataShape: RootEntityList

var result = Resources["EntityServices"].GetEntityList(params);

Note that you can use the Type to seach for different entities like Things, Mashups, Users etc

You can find this together with other EntityServices under the Snippets > EntityServices

Translate