- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2025 02:14 PM
Hey all!
I'm trying to see if I can use records in the value part of GlideRecord's addQuery() function. I already know I can do something like addQuery("column_name", integer) or addQuery("column_name", "string"), but there are some columns where the values are records from other tables. How do I go about putting a record in the value spot such that it looks something like addQuery("column_name", record)? Is this even possible with addQuery(), or at all?
Any help is greatly appreciated!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2025 02:28 PM
Hi @Goofing_Off
You have to use the sys_id of the record if the values are records from other table( i.e reference field)
addQuery("column_name", "sys_id_of_record");
What is the use-case you are trying to acheive?
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2025 02:28 PM
Hi @Goofing_Off
You have to use the sys_id of the record if the values are records from other table( i.e reference field)
addQuery("column_name", "sys_id_of_record");
What is the use-case you are trying to acheive?
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2025 02:41 PM
hi Rohila! I'm trying to filter a list of services from the cmdb_ci_service table using the "managed by" column. so far, the code looks like this:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2025 02:44 PM
wait, I realized I was copying the wrong item. I should be going to the table the record originates from, entering the edit menu of the record itself, and right clicking the top grey bar to copy the proper sys_id. Thank you so much!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2025 12:02 AM
Yesss but It's not recommended to use sys_id directly, make it dynamic.
If you want to filter with 1 particular managed by then store that record sys_id in a property and use gs.getProperty('propertyname') to get the value.I future if you want to change managed by with some other record then you can simply update the property value.
svs.addQuery("managed_by", gs.getProperty('property_name')); // create a property with relevant name and use it here.
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP