Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions Core ServiceNow APIs/GlideRecord/Get Reference Record/README.md
Original file line number Diff line number Diff line change
@@ -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.

This file was deleted.

Loading