Usage of g_form.setValue on a reference field without displayValue - Portal Widget clientScript
Impact area
Performance
Severity
High
Affected element
Widget
Rule ID
SN-0384
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');