Query List Field for only exact matches
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2020 03:53 AM
Looking for any suggestions to solve this puzzle...
I have a table with a List collector field which has a choice list based on the sys_user employee_type - so it's stored as a string with a list like "employee,contactor,vendor".
I want to query this table to see find a record containing a match for a specific employee type.
If I query with addQuery("employee_types","CONTAINS","employee") then I get the expected row but also get substring matches for our "Non-employee" employee type.
Is there a way via a regular GlideRecord query to make this only match on full list values or am I going to have to look through the returned records from the query and apply a regex match?
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2020 04:23 AM
I think your best bet is indeed to "look through the returned records from the query and apply a regex match".
If the employee type cannot contain both at the same time however, you can exclude values in your query like so:
gr.addQuery("employee_types","CONTAINS","employee");
gr.addQuery("employee_types","DOES NOT CONTAIN","Non-employee");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2020 04:58 AM
Thanks Willem - I was hoping for something I could do in the UI query filter too. But I guess I'll revert to looping through the list.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2020 06:14 AM
I don't think there is any option in Gliderecord query to do this.
You can loop through and can check like this
var arr = gr.your_list.toString().split(",");
if(arr.indexOf("employee") >-1) {
}
Mark the comment as a correct answer and also helpful if it helps to solve the problem.