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
- 2K Product Ideas
- 2K Ideas Exchange
- 1.6K Connect
- 1.3K Connectors
- 311 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 3.8K Transform
- 656 Datasets
- 115 SQL DataFlows
- 2.2K Magic ETL
- 813 Beast Mode
- 3.3K Visualize
- 2.5K Charting
- 81 App Studio
- 45 Variables
- 771 Automate
- 190 Apps
- 481 APIs & Domo Developer
- 77 Workflows
- 23 Code Engine
- 36 AI and Machine Learning
- 19 AI Chat
- AI Playground
- AI Projects and Models
- 17 Jupyter Workspaces
- 410 Distribute
- 120 Domo Everywhere
- 280 Scheduled Reports
- 10 Software Integrations
- 142 Manage
- 138 Governance & Security
- 8 Domo Community Gallery
- 48 Product Releases
- 12 Domo University
- 5.4K Community Forums
- 41 Getting Started
- 31 Community Member Introductions
- 114 Community Announcements
- 4.8K Archive