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

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

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

wcui
14-Alexandrite

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 *.

1 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
14-Alexandrite
(To:mneumann)

wcui
14-Alexandrite
(To:wcui)

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

# $ ^

Top Tags