- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2024 01:36 AM
Hi community,
what is the difference between g_form.getValue and g_form.getUniquevalue ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2024 01:40 AM - edited 02-14-2024 01:41 AM
In ServiceNow, both g_form.getValue() and g_form.getUniqueValue() are client-side JavaScript methods provided by the GlideForm API (g_form) for working with form fields. However, they serve slightly different purposes:
g_form.getValue(fieldName):
- This method is used to retrieve the display value of a field on the form
- .var fieldValue = g_form.getValue('field_name');
g_form.getUniqueValue():
- This method is used to retrieve the unique identifier (sys_id) of the current record.
- var uniqueValue = g_form.getUniqueValue();
- In summary, g_form.getValue() is used to retrieve the display value of a specific field on the form, while g_form.getUniqueValue() is used to retrieve the unique identifier (sys_id) of the current record. Depending on your use case, you would choose the appropriate method
Kindly mark helpful/accepted if it helps you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2024 01:41 AM
Hi,
g_form.getUniquevalue() does not require you to pass any argument, and it returns the sys id of the current record.
g_form.getValue('<field name>') -> this requires you to pass the field that you want to read , and it returns the value of that field on the form.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2024 01:41 AM
getValue() and getUniqueValue()
Both getValue() and getUniqueValue() will return a value from the GlideRecord upon which they're called.
getUniqueValue() accepts no arguments, and simply returns the primary key (the sys_id) of the record.
getValue() on the other hand, can return the value from any table column (including sys_id). It accepts one argument - a field name, and will return the value therein.
Please mark answer correct/helpful based on Impact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2024 01:40 AM - edited 02-14-2024 01:41 AM
In ServiceNow, both g_form.getValue() and g_form.getUniqueValue() are client-side JavaScript methods provided by the GlideForm API (g_form) for working with form fields. However, they serve slightly different purposes:
g_form.getValue(fieldName):
- This method is used to retrieve the display value of a field on the form
- .var fieldValue = g_form.getValue('field_name');
g_form.getUniqueValue():
- This method is used to retrieve the unique identifier (sys_id) of the current record.
- var uniqueValue = g_form.getUniqueValue();
- In summary, g_form.getValue() is used to retrieve the display value of a specific field on the form, while g_form.getUniqueValue() is used to retrieve the unique identifier (sys_id) of the current record. Depending on your use case, you would choose the appropriate method
Kindly mark helpful/accepted if it helps you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2024 01:41 AM
Hi,
g_form.getUniquevalue() does not require you to pass any argument, and it returns the sys id of the current record.
g_form.getValue('<field name>') -> this requires you to pass the field that you want to read , and it returns the value of that field on the form.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2024 01:41 AM
getValue() and getUniqueValue()
Both getValue() and getUniqueValue() will return a value from the GlideRecord upon which they're called.
getUniqueValue() accepts no arguments, and simply returns the primary key (the sys_id) of the record.
getValue() on the other hand, can return the value from any table column (including sys_id). It accepts one argument - a field name, and will return the value therein.
Please mark answer correct/helpful based on Impact