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

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

How use set wildcard characters [? % *] as target character in ThingWorx Query with "Like" filter?

wcui
16-Pearl

How use set wildcard characters [? % *] as target character in ThingWorx Query with "Like" filter?

There is a DataTable as below. How to get rows containing "%" ?

ID Value
1
%1
2
2?
3
*
4
+1

 

In above case, should be the 1st row.

Because % is a wildcard in Thing Query, how should I escape it?

Same question for ? and *.

ACCEPTED SOLUTION

Accepted Solutions
mneumann
16-Pearl
(To:wcui)

Try the following code to just return the "%1" line

 

 

var query = {
  "filters": {
    "fieldName": "value",
    "type": "LIKE",
    "value": "\\u0025" + "1"
  }
};

var params = {
	query: query /* QUERY */
};

// result: INFOTABLE dataShape: "undefined"
var result = me.QueryDataTableEntries(params);

 

The % is unescaped into \\u0025 to reflect the hex number of the character

https://www.ascii.cl/htmlcodes.htm

 

For me it returned only this one row out of

 

%1
2?
*
+1
11
12
21
22

View solution in original post

3 REPLIES 3
mneumann
16-Pearl
(To:wcui)

Try the following code to just return the "%1" line

 

 

var query = {
  "filters": {
    "fieldName": "value",
    "type": "LIKE",
    "value": "\\u0025" + "1"
  }
};

var params = {
	query: query /* QUERY */
};

// result: INFOTABLE dataShape: "undefined"
var result = me.QueryDataTableEntries(params);

 

The % is unescaped into \\u0025 to reflect the hex number of the character

https://www.ascii.cl/htmlcodes.htm

 

For me it returned only this one row out of

 

%1
2?
*
+1
11
12
21
22

wcui
16-Pearl
(To:mneumann)

wcui
16-Pearl
(To:wcui)

The Unicode marking method also works for below characters. It should be a common way for all characters.

# $ ^

Announcements


Top Tags