UI Actions with client=true execute in the browser where g_form is available to manipulate form fields directly. The critical mistake developers make is calling gsftSubmit() instead of g_form.save() after setting values. The gsftSubmit() method bypasses client-side validation and can cause race conditions where your setValue() calls haven't fully propagated to the form before submission.
When to use this
- When you need to set multiple related field values atomically before saving
- When you want client-side validation to run on the new field values
- When implementing approval workflows that update status fields and audit trails
- When you need immediate visual feedback in the form after the field changes
When NOT to use this
- Don't use for server-side calculations that require database queries — use a server-side UI Action instead
- Don't use when you need to update records other than the current form record — use
GlideAjaxto call a server-side Script Include - Don't use for fields that have complex business rules — the client-side save may fail validation
- Don't use on mobile interfaces where
g_formbehavior is inconsistent — use server-side UI Actions
Key behaviors and gotchas
- State field values must be strings even though they're stored as integers:
'3'not3 - The
return falseprevents the default UI Action submission — essential when usingg_form.save() - Reference fields require sys_ids as values, not display values — use
g_user.getUserID()notg_user.getName() - Date/time fields accept
g_form.getNow()for server timezone or JavaScriptDateobjects for local timezone - Field order in
setValue()calls matters when business rules have dependencies between fields - Client-side UI Actions run in the user's security context — ACLs still apply to field updates
Never mix g_form.save() with gsftSubmit() in the same UI Action. The gsftSubmit() will execute immediately while g_form.save() is asynchronous, creating a race condition where the form submits before your field values are applied.
Enjoying this? Get one deep-dive per week.
Join 1,000+ ServiceNow pros — scripts, GlideRecord patterns, Flow Designer techniques, and career moves. Free.