Skip to main content
Jul 25, 2019 8:33 AM UTC
Solved

Information about 'GetEntityList' service

Hello,

I m trying to use the 'GetEntityList' service in Thingworx which can be found in 'EntityServices' resource. This service has couple of parameters as below:

// result: INFOTABLE dataShape: "RootEntityList"
var result = Resources["EntityServices"].GetEntityList({
	maxItems: undefined /* NUMBER */,
	nameMask: "PART" /* STRING */,
	type: "Thing" /* STRING */,
	tags: "CMU_MT_IOTServer2.0:AUTO" /* TAGS */
});

I am not able to understand about 'nameMask'. How is this parameter used? Does it take Reg-Ex as input or does it work on 'contains' mechanism? Kindly share some information/samples/examples on how to use this parameter.

Thanks in advance.

-Aditya Mittal

khayes1Answer
Jul 25, 2019 9:29 AM UTC

Hi yes it is like reg-ex, so you could use filters such as:

 

"*PART*"   which would return anything that contains 'PART' in the name

or

"PART*"   which would return anything that begins with 'PART' in the name

or

"*PART"   which would return anything that ends with 'PART' in the name

 

so to get all Thing entities with 'PART' somewhere in the name you can use

var params = {
maxItems: undefined /* NUMBER */,
nameMask: "*PART*" /* STRING */,
type: "Thing" /* STRING */,
tags: "myTag" /* TAGS  if required*/
};

// result: INFOTABLE dataShape: RootEntityList
var result = Resources["EntityServices"].GetEntityList(params);

 

3 replies

khayes1Answer
Jul 25, 2019 9:29 AM UTC

Hi yes it is like reg-ex, so you could use filters such as:

 

"*PART*"   which would return anything that contains 'PART' in the name

or

"PART*"   which would return anything that begins with 'PART' in the name

or

"*PART"   which would return anything that ends with 'PART' in the name

 

so to get all Thing entities with 'PART' somewhere in the name you can use

var params = {
maxItems: undefined /* NUMBER */,
nameMask: "*PART*" /* STRING */,
type: "Thing" /* STRING */,
tags: "myTag" /* TAGS  if required*/
};

// result: INFOTABLE dataShape: RootEntityList
var result = Resources["EntityServices"].GetEntityList(params);

 

Jul 25, 2019 9:46 AM UTC

Hello,

 

Just to epand on @khayes1 answer:

  1. You can also use "?", which stands for a single character (analog of "." in regex)
  2. It looks like you can also use regex character classes and quantifiers, e.g. "Device-[0-9]{4}" to find "Device-0001", etc.

/ Constantine

amittal-3Author
Jul 25, 2019 11:01 AM UTC

Thanks Guys for the quick response

Regards

Aditya