What It Does

The getValue() method retrieves the raw database value of a field and converts it to a string. This is the actual value stored in the database column, not any formatted or display representation. For reference fields, this means you get the sys_id of the referenced record, not the display value you'd see in the UI.

ServiceNow performs a direct column read from the current record's data. The platform doesn't execute additional queries or joins – it simply returns whatever value exists in that field for the loaded record. Type conversion happens automatically: integers become string representations of numbers, booleans become 'true' or 'false', and dates become their internal string format.

The method returns an empty string for fields that exist but contain no value, and null for fields that don't exist on the table or fields you lack permission to read. Empty reference fields return an empty string, not null. Date fields return their internal representation (YYYY-MM-DD HH:mm:ss format), which differs from what getDisplayValue() would show.

Edge cases include choice fields returning the database value (like '1', '2', '3') rather than labels, and encrypted fields returning their encrypted values if you have the encryption context. Journal fields return the full text content as stored, including any formatting markers. Currency fields return the numeric value as a string without currency symbols or formatting.

This method is the complement to setValue() and the counterpart to getDisplayValue(). Where getDisplayValue() performs additional processing for human readability, getValue() gives you exactly what's in the database.

When to Use This

Use getValue() when you need the actual database value for programmatic operations: building queries, making comparisons, setting other fields, or sending data to external systems. This is essential for reference fields where you need the sys_id for addQuery() operations or REST API calls. It's also the right choice for integer and boolean fields when you need to perform calculations or logical operations.

Don't use getValue() when you need formatted output for users or logs – use getDisplayValue() instead. Avoid it for user-facing messages where you want readable dates, choice labels, or reference field display names. Common mistakes include using getValue() for notification templates or UI messages where display values would be more appropriate.

Return Value

Returns a string representation of the field's database value. For empty fields that exist on the table, you get an empty string (''), not null. For fields that don't exist or fields you can't read due to ACL restrictions, you get null. Reference fields return the 32-character sys_id string, while choice fields return the internal choice value.

Always check for null before using the return value if there's any chance the field might not exist. Use if (value) to check for both null and empty string in one test, or if (value !== null) if you need to distinguish between null and empty string.

Free Newsletter

Enjoying this? Get one deep-dive per week.

Join 1,000+ ServiceNow pros — scripts, GlideRecord patterns, Flow Designer techniques, and career moves. Free.

No spam · Unsubscribe anytime

Platform Behavior & Side Effects

  • No Business Rules, Script Engines, or notifications fire – this is a read-only operation
  • No database writes occur and no audit trail entries are created
  • Performance is fast – reads from the already-loaded record data in memory
  • ACL read restrictions still apply – you'll get null for fields you can't access
  • Works identically in before/after Business Rules, Script Includes, and Scheduled Jobs
  • Field values reflect the current state of the loaded record, including any previous setValue() calls
⚠️

getValue() on reference fields only works if the GlideRecord was queried with that field included. Dot-walking (gr.caller_id.name.getValue()) requires the reference to be populated first.