Available query operators

We can use the following 13 different JavaScript operators in the addQuery method:

Operator

Type

Code example

=

Value of field must be equal to value supplied

addQuery('priority', '=' , 2);

>

Value of field must be greater than value supplied

addQuery('priority', '>', 1);

<

Value of field must be less than value supplied

addQuery('priortiy', '<', 3);

>=

Value of field must be equal or greater than value supplied

addQuery('priority', '>=', '2');

<=

Value of field must be equal or less than value supplied

addQuery('priority', '>=', '2');

!=

Value of field must not be equal to the value supplied

addQuery('priority', '!=', '1');

STARTSWITH

Value of field must start with the value supplied

addQuery('short_description', 'STARTSWITH', 'CRIT');

CONTAINS

Value of field must contain the value supplied

addQuery('short_description', 'CONTAINS', 'Server');

IN

Value of field must be equal to one of the values supplied as comma-separated list

addQuery('category', 'IN', 'Software,Network');

ENDSWITH

Value of field must end with the string supplied as value

addQuery('short_description', 'ENDSWITH', 'Error');

DOES NOT CONTAIN

Value of field must not contain the string supplied as value

addQuery('short_description', 'DOES NOT CONTAIN', 'Server');

NOT IN

Value of field must not be equal to the values present in the comma delimited list

addQuery('category', 'NOT IN', 'Software,Network');

INSTANCEOF

This is a special operator that can be used to query records of extended tables in the parent table.

We can query the task table to find all records that belong to the class incident or problem by passing the correct table/class name.

Example 1:

var gr = new GlideRecord('task');

gr.addQuery('sys_class_name', 'INSTANCEOF', 'incident');

Example 2:

var gr=new GlideRecord('cmdb_ci);

gr.addQuery('sys_class_name', 'INSTANCEOF', 'cmdb_ci_computer');

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.65.65