Hey {{first_name | default: 'there'}},
Quick one this week — a field that almost every developer sets incorrectly, causing subtle bugs that are painful to track down.
💡 This week's tip: Stop using setValue() when you mean setDisplayValue()
Here is a pattern that shows up constantly in ServiceNow scripts:
// This looks right but stores strings in integer fields var gr = new GlideRecord('incident'); gr.state = 'In Progress'; // ❌ ERROR
The problem: State is an integer field. 'In Progress' is just the label. Storing the string directly often results in a 0 or a silent failure.
The Correct Ways:
// Option 1: Set actual integer value gr.state = 2; // Option 2: Use setDisplayValue for labels gr.setDisplayValue('state', 'In Progress');
Quick rule: If a field is a dropdown or choice list, the stored value is almost certainly an integer or a short code, not the text you see.
📚 From the blog
A complete reference for how ServiceNow stores data by type.
🚀 New: CMDB Mastery Guide
We just published the CMDB Mastery Guide — 21 pages covering CI hierarchy, Discovery flows, and Health scoring.
Get the CMDB Mastery Guide — $29Until next week,
The NowSpectrum Team
NowSpectrum · nowspectrum.com