GlideRecord getUniqueValue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2020 03:06 AM
Is getUniqueValue a valid GlideRecord method? It is not listed in the GlideRecord documentation, but can be selected from the intellisense menu in a ServiceNow script editor.
If gr is a GlideRecord object, Is it better to use gr.sys_id or gr.getValue('sys_id') to retrieve the sys_id as a string? When I have referenced the sys_id property in a workflow script it seems to return an object rather than a string.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2020 03:19 AM
Hi Colleen,
getUniquevalue() is documented here -
it is recommended to use getUniqueValue() as it guarantees the string value.
getValue() also returns the string value but calling the property directly [gr.sys_id] can be of type object or string it doesn't guarantee anything. That's why avoid calling property instead use getValue or getUniqueValue() for sys_ids.
See a quick comparison at below link
https://grow.usecoda.com/use-gr-getuniquevalue
Hope that helps!
Thanks,
Sharjeel
Muhammad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2020 03:36 AM
Thanks for the information.
The unique record identifier page references getUniqueValue as a method of g_form, not GlideRecord. The information on the CODA page is helpful, but it is not official ServiceNow documentation, as far as I can tell.
I asked about the getUniqueValue GlideRecord method because I was using it in a ATF configuration step script that was returning inconsistent results. Since I replaced getUniqueValue with getValue('sys_id'), the script has worked correctly. I was therefore looking for some clarity on the getUniqueValue GlideRecord method.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2020 03:53 AM
There are many methods that are not documented in official documentation but those are widely used and recommended.
It is being used in OOB scripts as well, I just queried the business rules containing getUniqueValue and got 350 OOB BRs. See the screenshot for reference.
Maybe it has issues in ATFs only. As, I never used getUniqueValue in ATF so not sure about that.
Muhammad

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2020 11:36 PM
Do we need a follow up on this or is this answered? If answered. please close the thread by marking the appropriate response as correct and helpful. That will help others looking for the same solution, in the future.
Have a nice day & Stay Safe! 🙂
Thanks & Regards,
Sharjeel
Muhammad