.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2025 05:10 AM - edited ‎07-09-2025 03:03 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2025 05:14 AM
@Kadasiddeshwar
If multiple records are found then you can glide the list of records using next()
get(Object name, Object value)
This method accepts either one or two parameters. If only a single parameter is passed in, the method assumes that it is the sys_id of the desired record. If not found, it then tries to match the value against the display value. If two parameters are passed in, the first is the name of the column within the GlideRecord to search. The second is the value to search for. If multiple records are found, use next() to access the additional records.
https://developer.servicenow.com/dev.do#!/reference/api/yokohama/server/no-namespace/c_GlideRecordSc...
Please mark as complete if I have answered your question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2025 05:20 AM
The get() method is designed to retrieve a record by its sysid. Because category is not a unique key and 'inquiry' is not a valid sys_id, you will probably get an 'undefined' number, or maybe a random incident.
Why would you want to use it like this? What is your business requirement that this script should be used?
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2025 05:29 AM - edited ‎06-05-2025 05:35 AM
Hi @Kadasiddeshwar ,
looks like
when you are querying records with get
it will filter the records with the query and order the records using the same field from a to z (in this case it's category) and return the first record
example 2
get using priority
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2025 05:41 AM
Hi @Kadasiddeshwar ,
To answer your question specifically, when multiple records match the .get() method query, the first matching record (as determined by the database engine) is returned.
Please note, It is non deterministic meaning the order is not guaranteed or applied. Specifically, sys_updated_on or sys_created_on are not applied.
For reference and context - the .get() method was introduced and was designed to use as a 'short hand' if you like and return a specific record in the GlideRecord object.
See the following SN developer docs and API reference: https://developer.servicenow.com/dev.do#!/reference/api/yokohama/server/no-namespace/c_GlideRecordSc...
To help others (and for me to gain recognition for my efforts), please mark this response correct by clicking on Accept as Solution and/or Kudos.
Thanks, Robbie