How to format "or" clause in Query?
I have this Javascript and I'm trying to make an OR clause for the where but I cannot figure out the syntax and the manual does not show any OR examples.
query
.select([…snipped…) // <- specify select columns here
.where('errorMessage').contains('Some text')
.or('errorMessage').contains('Some other text')
.limit(1000);
Best Answer
-
The .limit() issue may be caused by that query syntax hitting a structural limitation in the framework. There are a few alternate approaches you might try to keep the workflow without creating a new column.
1. Apply Multiple .where() Clausesquery .select([...]) .where('errorMessage').contains('Some text') .where('errorMessage').contains('Some other text') .limit(1000);
If this returns no rows, Domo may be interpreting it as a AND not OR.
2. Filter with a custom function and use .filter()const results = await query .select([...]) .limit(1000); const filteredResults = results.filter(row => row.errorMessage.includes('Some text') || row.errorMessage.includes('Some other text') );
or
3. Use .where() in a regular expression to capture conditions. Or create a new calculated field in Domo.** Was this post helpful? Click Agree or Like below. **
** Did this solve your problem? Accept it as a solution! **0
Answers
-
Sorry, this got posted in the wrong area by accident. Not sure where to post HTML Bricks questions and there isn't any way to move a topic that I can find.
0 -
Domo's Javascript may not support .or(). Using the following code, you should be able to get the include to return true if either condition is met….creating an or condition.
query
.select([...]) // <- specify select columns here
.where(row => row.errorMessage.includes('Some text') || row.errorMessage.includes('Some other text'))
.limit(1000);** Was this post helpful? Click Agree or Like below. **
** Did this solve your problem? Accept it as a solution! **2 -
Thanks!
I had to remove the .limit() function to make that work or I get a javascript error. however, it is returning all rows in the table, even if the error message does not include the required text. For testing, I changed || to && and it still returned 100% of rows.
It seems so weird that it is so difficult to create an OR condition. I've been working on this for a few hours now and it's gotten quite frustrating. I have several HTML tables all filtering based on specific text in the error message. This is the only one I have that requires two different keys. I already have several of these completed and I really didn't want to go back to create a function to assign error types to a new column because that would require a lot of refactoring of the other dashboards. It seems like that might be the most straightforward solution even though it feels so unnecessary.0 -
The .limit() issue may be caused by that query syntax hitting a structural limitation in the framework. There are a few alternate approaches you might try to keep the workflow without creating a new column.
1. Apply Multiple .where() Clausesquery .select([...]) .where('errorMessage').contains('Some text') .where('errorMessage').contains('Some other text') .limit(1000);
If this returns no rows, Domo may be interpreting it as a AND not OR.
2. Filter with a custom function and use .filter()const results = await query .select([...]) .limit(1000); const filteredResults = results.filter(row => row.errorMessage.includes('Some text') || row.errorMessage.includes('Some other text') );
or
3. Use .where() in a regular expression to capture conditions. Or create a new calculated field in Domo.** Was this post helpful? Click Agree or Like below. **
** Did this solve your problem? Accept it as a solution! **0
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.6K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 101 SQL DataFlows
- 622 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 748 Beast Mode
- 59 App Studio
- 41 Variables
- 686 Automate
- 176 Apps
- 453 APIs & Domo Developer
- 47 Workflows
- 10 DomoAI
- 36 Predict
- 15 Jupyter Workspaces
- 21 R & Python Tiles
- 396 Distribute
- 113 Domo Everywhere
- 276 Scheduled Reports
- 7 Software Integrations
- 125 Manage
- 122 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 109 Community Announcements
- 4.8K Archive