on ‎2024 Jun 24 3:04 PM
Hello everyone,
I am using Cap Node.js (odata v4) which is connected to an external API(odata v2) through a destination. I'm implementing search functionality in Valuehelp dialog box and for that I need to query the external database because by default when you type some value in the search bar it only searches for that value in the Primary key column. I was using contains function to build the query and it works if it has only one column i.e.
let query = cds.parse.cql(`SELECT * from DUMMY WHERE contains(firstName, '${req.query.SELECT.search[0].val}')`);
But when I try to search in multiple columns using the following statement it gives an error:
let query = cds.parse.cql(`SELECT * from DUMMY WHERE contains((firstName,lastName)), '${req.query.SELECT.search[0].val}')`);
I have also tried using multiple contains and that works fine with the 'and' operator i.e. It gives me names that are common in both columns
let query = cds.parse.cql(`SELECT * from DUMMY WHERE contains(firstName, '${req.query.SELECT.search[0].val}') and contains(lastName, '${req.query.SELECT.search[0].val}'`);
But when I try to use use the query with 'or' operator it doesn't work and just returns all the values. Any suggestions on how to search in multiple columns ?
Request clarification before answering.
| User | Count |
|---|---|
| 11 | |
| 6 | |
| 6 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.