Skip to content

Commit 7494a5c

Browse files
authored
Issue 1903/fix naming combine (#1977)
* Update README.md Updated the readme to combine the readme for both JS files. There are now 2 readme's which is confusing and reported in issue #1903 * Delete Core ServiceNow APIs/GlideRecord/Get Reference Record/Readme_Soumyadeep.md Removed additional readme, as the naming is not in line, and another readme already exists. Updated the other readme to include the content of this one + improvements. * Rename script.js to get_assignment_group_from_incident.js Rename the script to account for the second JS file in this folder. This is the name also referred to in the readme * Rename GetRecordRequestedBy_Soumyadeep.js to get_requested_by_user.js Renamed the file to account for a second js in this folder. This file name is also referenced in the updated readme.
1 parent 2b57510 commit 7494a5c

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed
Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1-
# Get Reference Record
1+
# Get Reference Record with GlideRecord
22

3-
If you need a GlideRecord object for a reference item, then getRefRecord() is the method to use. You must call isValidRecord() after getting the reference record as getRefRecord() does not throw errors for empty values. isValidRecord() will be true if your reference record was found.
3+
This folder contains examples demonstrating how to retrieve and work with reference records using `getRefRecord()` in ServiceNow server-side scripting.
4+
5+
## Overview
6+
7+
`getRefRecord()` is used to retrieve the full GlideRecord object of a reference field. This allows access to additional fields from the referenced record, such as `name`, `email`, or other attributes beyond the display value.
8+
9+
Because `getRefRecord()` does not throw an error when the reference field is empty or invalid, it is important to use `isValidRecord()` to verify that the reference was successfully retrieved before accessing its fields.
10+
11+
## Script Descriptions
12+
13+
- get_assignment_group_from_incident.js retrieves the assignment group from an incident record and prints its name if the group exists.
14+
- get_requested_by_user.js retrieves a change request by `sys_id`, then accesses the `requested_by` user record. If valid, it prints the user's username and email.
15+
16+
## Best Practices
17+
18+
- Always use `isValidRecord()` after calling `getRefRecord()` to ensure the reference is valid.
19+
- Use `getRefRecord()` when you need to access fields from a referenced record, not just its display value.

Core ServiceNow APIs/GlideRecord/Get Reference Record/Readme_Soumyadeep.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

Core ServiceNow APIs/GlideRecord/Get Reference Record/script.js renamed to Core ServiceNow APIs/GlideRecord/Get Reference Record/get_assignment_group_from_incident.js

File renamed without changes.

Core ServiceNow APIs/GlideRecord/Get Reference Record/GetRecordRequestedBy_Soumyadeep.js renamed to Core ServiceNow APIs/GlideRecord/Get Reference Record/get_requested_by_user.js

File renamed without changes.

0 commit comments

Comments
 (0)