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
- Product Ideas
- 2.1K Ideas Exchange
- Connect
- 1.3K Connectors
- 309 Workbench
- 7 Cloud Amplifier
- 10 Federated
- Transform
- 663 Datasets
- 119 SQL DataFlows
- 2.3K Magic ETL
- 823 Beast Mode
- Visualize
- 2.6K Charting
- 86 App Studio
- 46 Variables
- Automate
- 194 Apps
- 483 APIs & Domo Developer
- 87 Workflows
- 23 Code Engine
- AI and Machine Learning
- 23 AI Chat
- 4 AI Projects and Models
- 18 Jupyter Workspaces
- Distribute
- 118 Domo Everywhere
- 283 Scheduled Reports
- 11 Software Integrations
- Manage
- 143 Governance & Security
- 11 Domo Community Gallery
- 49 Product Releases
- 13 Domo University
- Community Forums
- 41 Getting Started
- 31 Community Member Introductions
- 116 Community Announcements
- 5K Archive