diff --git a/Core ServiceNow APIs/GlideRecord/Get Reference Record/README.md b/Core ServiceNow APIs/GlideRecord/Get Reference Record/README.md index 5735162344..c6a9bbf547 100644 --- a/Core ServiceNow APIs/GlideRecord/Get Reference Record/README.md +++ b/Core ServiceNow APIs/GlideRecord/Get Reference Record/README.md @@ -1,3 +1,19 @@ -# Get Reference Record +# Get Reference Record with GlideRecord -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. +This folder contains examples demonstrating how to retrieve and work with reference records using `getRefRecord()` in ServiceNow server-side scripting. + +## Overview + +`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. + +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. + +## Script Descriptions + +- get_assignment_group_from_incident.js retrieves the assignment group from an incident record and prints its name if the group exists. +- 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. + +## Best Practices + +- Always use `isValidRecord()` after calling `getRefRecord()` to ensure the reference is valid. +- Use `getRefRecord()` when you need to access fields from a referenced record, not just its display value. diff --git a/Core ServiceNow APIs/GlideRecord/Get Reference Record/Readme_Soumyadeep.md b/Core ServiceNow APIs/GlideRecord/Get Reference Record/Readme_Soumyadeep.md deleted file mode 100644 index 698348475d..0000000000 --- a/Core ServiceNow APIs/GlideRecord/Get Reference Record/Readme_Soumyadeep.md +++ /dev/null @@ -1,3 +0,0 @@ -This script will glide for a particular record whose sys id has been provided -It will fetch the record and then use getRefRecord() to fetch the requested by user details. -If the user is a valid record, then it will fetch the user_name and email. diff --git a/Core ServiceNow APIs/GlideRecord/Get Reference Record/script.js b/Core ServiceNow APIs/GlideRecord/Get Reference Record/get_assignment_group_from_incident.js similarity index 100% rename from Core ServiceNow APIs/GlideRecord/Get Reference Record/script.js rename to Core ServiceNow APIs/GlideRecord/Get Reference Record/get_assignment_group_from_incident.js diff --git a/Core ServiceNow APIs/GlideRecord/Get Reference Record/GetRecordRequestedBy_Soumyadeep.js b/Core ServiceNow APIs/GlideRecord/Get Reference Record/get_requested_by_user.js similarity index 100% rename from Core ServiceNow APIs/GlideRecord/Get Reference Record/GetRecordRequestedBy_Soumyadeep.js rename to Core ServiceNow APIs/GlideRecord/Get Reference Record/get_requested_by_user.js