How to add Or condition with Null
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-29-2015 12:13 PM
Hi,
I can use addNotNullQuery or addNullQuery on a field as a filter. I can use addOrCondition to add a Or condition on a field. However, how can I add a Null Or condition on a field? For example, field1 = '123' or field1 IS Null.
Thanks,
Eric
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-29-2015 12:22 PM
I would do one condition with the addOrCondition and follow that up with the nullQuery like so...
var gr = new GlideRecord('table_name');
gr.addQuery('field', 'value');
gr.addOrCondition('field', 'value');
var q = gr.addNullQuery('field', value);
gr.query();
Not even sure if that'll work but it's the first thing that came to mind...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-29-2015 12:23 PM
or even try
var gr = new GlideRecord('table_name');
gr.addQuery('field', 'value');
gr.addOrCondition('field', 'value');
var q = gr.addOrCondition('field', 'value');
gr.query();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-30-2015 03:31 AM
var gr = new GlideRecord('');
var qc = gr.addQuery('field', 'value1');
qc.addOrCondition('field', 'value2');
gr.query();
while (gr.next()) {
//do your stuff
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-30-2015 03:38 AM
Hope this helps
var x = null;
var a= new GlideRecord(tablename);
var b= a.addQuery('fieldname', '123');
b.addOrCondition('fieldname1', 'x');
a.query();
while (a.next()) {
.....
}