Dot walking to sys_id - Catalog UI Policy scriptFalse

Impact area

Performance

Severity

Medium

Affected element

Catalog UI Policy

Rule ID

SN-0382

Impact

The value of a reference field is a sys_id. When you dot-walk to the sys_id, the system does an additional database query to retrieve the referenced record, then retrieves the sys_id. This can lead to performance issues.

Remediation

Avoid dot walking to sys_id, instead call the field as normal.

Time to fix

10 min

Code examples

Noncompliant code

It is not necessary to include the sys_id of a reference field when dot-walking, as in the following example:

var id = current.caller_id.sys_id; // Wrong

Compliant code

The value of a reference field is a sys_id. When you dot-walk to the sys_id, the system does an additional database query to retrieve the caller_id record, then retrieves the sys_id. This can lead to performance issues. Instead, use the statement.

var id = current.getValue('caller_id'); // Right




Last modified on Mar 25, 2021