Usage Of g_form.setValue On A Reference Field Without displayValue – UI Policy scriptFalse

< 1 min read

Impact Area

Performance

Severity

High

Affected Element

UI Policy

Rule ID #

SN-0386

Impact #

The usage of g_form.setValue() on a reference field without displayValue causes ServiceNow instance to do a synchronous call to retrieve the display value for the specified record, this extra step can lead  to performance issues.

Remediation #

Avoid the usage of g_form.setValue() without the displayValue parameter.

Time to fix #

10 min

Code examples #

Noncompliant code #

g_form.setValue(‘location’,’67ub8d1b0aaa07b3007a3d3a6b801f5b’);

Compliant code #

g_form.setValue(‘location’,’67ub8d1b0aaa07b3007a3d3a6b801f5b’,’Custom display value’);

Updated on March 21, 2025