The g_form.flash() method draws user attention by briefly pulsing a field's background color. Most developers stumble on the color parameter β it requires hex colors without the # prefix, and silently fails if you include it. The flashing is purely cosmetic β it doesn't affect field validation or data processing, making it perfect for highlighting auto-populated values without interfering with business logic.
When to use this
- After auto-populating fields based on user selections (caller ID populates department, location)
- When validation rules modify field values and users need to notice the changes
- To highlight calculated fields that update based on form interactions
- After successful GlideAjax calls that populate multiple fields simultaneously
When NOT to use this
- Don't flash error states β use
g_form.addErrorMessage()or field-level validation instead - Don't flash on every field change β users will ignore it if overused
- Don't use for critical alerts that require user acknowledgment β flash is easily missed
- Don't flash readonly or hidden fields β the animation won't be visible
Key behaviors and gotchas
- Color parameter must be 6-digit hex without
#prefix βFF0000not#FF0000 - Count parameter defaults to 2 flashes β values above 5 become annoying to users
- Flash executes immediately β no delay parameter exists, so sequence multiple flashes carefully
- Works on reference fields but flashes the display value field, not the dropdown button
- No effect in mobile UI β the animation only works in desktop browsers
Never call g_form.flash() inside a loop with the same field name β only the last flash will execute. If you need to flash after processing multiple records, consolidate into a single flash call at the end.
Enjoying this? Get one deep-dive per week.
Join 1,000+ ServiceNow pros β scripts, GlideRecord patterns, Flow Designer techniques, and career moves. Free.