Database Views - multiple conditions on a where clause
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-12-2009 09:51 PM
So I built a database view with the following ...
TABLE: metric_definition ORDER: 100 WHERE CLAUSE: md_table = 'incident' && md_name = ' TCS...
TABLE: metric_instance ORDER: 200 WHERE CLAUSE: mi_definition = md_sys_id
TABLE: incident ORDER: 300 WHERE CLAUSE: mi_id = inc_sys_id
But I'd also like to put a condition where the incident's assignment group = a specific group (xyz)
I've tried using all kinds of syntax (AND, and, &&, &) to no effect. I'm thinking there's something fundamental I'm just not getting.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2012 08:29 AM
I believe you have to put () around your && ||
http://wiki.servicenow.com/index.php?title=Talk:Database_Views

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2019 02:21 AM
Hello,
Here is an updated wiki link in case someone needs it: https://docs.servicenow.com/bundle/madrid-platform-administration/page/use/reporting/concept/c_UseDi....
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2024 08:08 AM
Hi.
I faced a similar challenge and my dev team told me that a Business Rule would make the trick.
- Create a Business Rule, name it, and on the "Table" drop-down, select your view.
- Check "Advanced" checkbox, to enable the Advanced Tab
- On "Where to Run" make sure you have When='before' and check the 'Query' box
- On Advanced, create a text variable that will contain the query expression (In another tab I opened my database and "Try it", applied filters to the list, right click on the filter and "Copy query" to copy the expression)
- use current.addquery(var name); to add it to the query
- Submit/Update
- Try your view again
- Magic!
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var query = "in_sys_created_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()^ORin_sys_created_onISEMPTY^ah_model_category=b7d5bc14c3031000b959fd251eba8fd0^ORah_model_category=";
current.addQuery(query);
})(current, previous);
Hope it helps!