Difference between getDisplayBox(), getValue() and getDisplayValue() method
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2024 07:21 AM - edited 08-21-2024 07:22 AM
Hi All,
Can any one explain the difference between getDisplayBox(), getValue() and getDisplayValue() method in servicenow and when to use these methods.
Thanks in advance,
Vinuth
- 1,647 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2024 07:33 AM
Enter the method name in the left navigation search box.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2024 07:59 AM - edited 08-21-2024 08:05 AM
Hi @vinuth v
To test this, open any form, like the Incident form in ServiceNow. Then, press Ctrl + Shift alt + j to access the browser-level JavaScript executor.
getDisplayBox() deals with the HTML element of the field, allowing direct manipulation of the form's user interface.
example: alert(g_form.getControl('short_description').getDisplayBox());
getValue() retrieves the raw data stored in the field, such as the sys_id for reference fields.
example: alert(g_form.getValue('caller_id'));
getDisplayValue() retrieves the user-friendly display value of the field, such as a user’s name instead of a sys_id.
example: alert(g_form.getDisplayValue('caller_id'));
Mark it Helpful and Accept Solution!! If this helps you to understand.