addQuery()

The addQuery() method of the GlideRecord class can be called in three different ways, depending on whether one, two, or three arguments are supplied to it. If one argument is passed into the addQuery() method, then it'll assume that the argument is an encoded query. Encoded queries are a single string that represents all of the conditions in a single query (or even multiple queries)!

There isn't any official documentation on how to construct an encoded query (though it isn't hard to figure out), but there is a very easy to build one yourself - simply navigate to the table you want to run the query on, and use the query builder! For example, here's a query on the incident table where the "assigned to" user is active, and either the Incident is active, or the state is set to new, in progress, or on hold:

You can build a filter on a given table using the query builder, and then apply that same filter to your GlideRecord query by simply right-clicking the last condition in the query breadcrumbs above the list view, and clicking on Copy query.

This is similar to the legacy addEncodedQuery() method:

You'll see an example of this single-argument usage in the following section. On the other hand, if you pass in two arguments, then it is assumed that the first argument is the field name, and the second argument is the expected value.

Finally, if you pass in three arguments to the addQuery() method, you may specify not only a field and value, but an operator between them. Operators that you can use as the second argument in this case, include some rather standard operators with obvious meaning, as well as some others for more advanced functionality. You'll find a list of available operators in the following table.

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

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