The g_form.isNewRecord() method is the definitive way to distinguish between record creation and editing in client scripts. It returns a boolean based on whether the current form has a sys_id value — new records don't have one yet, existing records do. This simple check enables completely different UX flows: showing field defaults and creation guidance for new records, versus workflow controls and history for existing ones. The most common mistake is assuming you can check sys_id directly, but isNewRecord() handles the edge cases and null checks for you.

When to use this

  • Setting different field defaults or visibility rules between new and existing records
  • Showing contextual help messages or warnings that only apply during creation or editing
  • Controlling field editability based on whether the record has been saved before
  • Implementing different validation rules for creation versus updates

When NOT to use this

  • Don't use in server-side scripts — use current.isNewRecord() in Business Rules instead
  • Don't rely on this for detecting clones — cloned records return false even though they need a new sys_id
  • Don't use for complex workflow logic — consider UI Actions with conditions or UI Policies instead
  • Don't check this in onSubmit if you need the value post-save — it will still return true

Key behaviors and gotchas

  • Returns false on cloned records because they temporarily have the original record's sys_id until save
  • Works consistently across all form load scenarios: direct navigation, related list clicks, and reference field popup forms
  • Value doesn't change during the form session — a new record stays true until page refresh after save
  • Mobile and Service Portal forms support this method with identical behavior to classic UI
  • Template-created records return true because templates populate fields but don't create the record yet
  • URL parameters like sysparm_copy_source don't affect the return value — only actual sys_id presence matters
⚠️

Clone operations return false because the form loads with the source record's sys_id. Use g_form.getValue('sys_id') != g_form.getUniqueValue() to detect clones if you need different behavior for them.

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