Scoped GlideQueryCondition - addOrCondition(String name, String oper, Object value)

Appends a 2-or-3 parameter OR condition to an existing GlideQueryCondition.

addOrCondition() works in conjunction with any of the Scoped GlideRecord - addQuery(String name, String operator, Object value) methods to OR the specified query parameters to the query previously constructed using addQuery().

addOrCondition() is typically called with three parameters; table field, operator, and comparison value. It can be called with only two parameters, table field and comparison value, such as qc.addOrCondition('category', 'software');. The operator in this case is assumed to be "equal to".

Table 1. Parameters
Name Type Description
name String Field name
oper String (Optional) Query operator. The available values are dependent on the data type of the value parameter.
  • =
  • !=
  • >
  • >=
  • <
  • <=
Strings (must be in upper case):
  • =
  • !=
  • IN
value Object Value on which to query (not case-sensitive).
Note: All passed in arrays must contain a minimum of two elements. Single element arrays are not supported.
Table 2. Returns
Type Description
GlideQueryCondition A reference to a GlideQueryConditon that was added to the GlideRecord.
var gr = new GlideRecord('incident');
var qc = gr.addQuery('category', 'Hardware');
qc.addOrCondition('category', 'Network');

To group AND/OR statements such as (state < 3 OR state > 5) AND (priority = 1 OR priority = 5) use code similar to the following:

var myObj = new GlideRecord('incident');
var q1 = myObj.addQuery('state', '<', 3);
q1.addOrCondition('state', '>', 5);
var q2 = myObj.addQuery('priority', 1);
q1.addOrCondition('priority', 5);