Skip to main content
1-Visitor
August 31, 2018
Solved

JavaScript Queries

  • August 31, 2018
  • 1 reply
  • 2820 views

 Hello, i'm trying to query an InfoTable column using multi-input, to illustrate: 

My InfoTable data shape is like this : Code(number) , Product(string) & Line (string), the line field contains a lot of numbers seperated by - 

I want my JS query to return ligns ending with 922 or 921. the query i wrote is this : 

var query = {
"filters": {
"fieldName": "Line",
"type": "LIKE",
"value": criteria
}
};

var params = {
t: me.myProdInfoTable /* INFOTABLE */,
query: query /* QUERY */
};

// result: INFOTABLE
var result = Resources["InfoTableFunctions"].Query(params);

With criteria as my string input. the query works when i put %22 but does not work when i put "%22", "%21". Can anyone help me, thank you

Best answer by CarlesColl

You need and OR condition, or if the infotable it's not big, just iterate on a for loop and check for the desired lines.

 

To do the or condition it will be something like:

 

var query = {
 "filters": {
 "type": "OR",
 "filters": [
 {
 "fieldName": "Line",
 "type": "LIKE",
 "value": : criteria1
 },
 {
 "fieldName": "Line",
 "type": "LIKE",
 "value": : criteria2
 }
 ]
 }
};

1 reply

19-Tanzanite
August 31, 2018

Hello @i_abidi

 

Try this query,

 

var criteria = "*" + YOURINPUT
var query = {
 "filters": {
 "fieldName": "Line",
 "type": "LIKE",
 "value": criteria 
 }
};

Thanks,

VR

 

 

 

 

 

i_abidi1-VisitorAuthor
1-Visitor
August 31, 2018

Still not working, it returns an empty table when it's suppose to return a couple of rows

1-Visitor
September 3, 2018

You need and OR condition, or if the infotable it's not big, just iterate on a for loop and check for the desired lines.

 

To do the or condition it will be something like:

 

var query = {
 "filters": {
 "type": "OR",
 "filters": [
 {
 "fieldName": "Line",
 "type": "LIKE",
 "value": : criteria1
 },
 {
 "fieldName": "Line",
 "type": "LIKE",
 "value": : criteria2
 }
 ]
 }
};