Created
September 7, 2018 14:37
-
-
Save cmcdevitt/7076eb412078ceb806b08f6635ce163e to your computer and use it in GitHub Desktop.
Add an "OR" Condition to a GlideRecord Query in ServiceNow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var myLog = ""; | |
| var gr = new GlideRecord("sys_user"); | |
| //New object to build OR query | |
| var q1 = gr.addQuery("title", "CONTAINS", "VP"); | |
| q1.addOrCondition("title", "CONTAINS", "Vice"); | |
| q1.addOrCondition("title", "CONTAINS", "Chief"); | |
| //"switch back" to the GR object | |
| gr.query(); | |
| while (gr.next()) { | |
| myLog += gr.title + ", "; | |
| } | |
| gs.addInfoMessage("VPs : " + myLog); | |
| gs.log("***CM: " + myLog, "CM"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note that there is also another way to add an OR query: you can use .addEcodedQuery() and then ^NQ to start a new query.
This is the same as writing (some query) OR (some other query).