Glide List validation issue in Before Insert Business Rule – value not fully populated
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi Team,
I’m working on a requirement in ServiceNow (GRC module) and facing an issue while validating a glide list field in a Business Rule.
🔹 Requirement
On table: Authority Documentsn_compliance_authority_document
We have:
u_applicability_confirmation_by_cao→ Reference field (sys_user)u_circular_cao→ Glide List (sys_user)
👉 Requirement is:
The selected value in
u_applicability_confirmation_by_caomust be present inu_circular_cao
Otherwise, the record should not be saved.
🔹 Approach Used
We implemented a Before Insert Business Rule to validate this.
🔹 Script Used
(function executeRule(current, previous) {
var applicabilityUser = current.getValue('u_applicability_confirmation_by_cao');
var circularList = current.getValue('u_circular_cao');
if (!circularList) {
gs.addErrorMessage('Circular CAO list is empty.');
current.setAbortAction(true);
return;
}
var circularArray = circularList.split(',');
for (var i = 0; i < circularArray.length; i++) {
circularArray[i] = circularArray[i].trim();
}
gs.info('Applicability user: ' + applicabilityUser);
gs.info('Circular list: ' + circularList);
gs.info('Array: ' + circularArray);
if (circularArray.indexOf(applicabilityUser) == -1) {
gs.addErrorMessage('The user in "Applicability Confirmation By CAO" is not present in the "Circular CAO" list.');
current.setAbortAction(true);
}
})(current, previous);🔹 Issue Observed
The Business Rule is getting executed multiple times during record creation, and the glide list field (u_circular_cao) is not fully populated in the first execution.
🔹 Logs Observed - BR is triggering Two times
Circular list: fe55d0d1b5dc11059d8a9ffe54bcb14
Application user: ba91ab5587b3b6581e95c8070cbb356f
Array: fe55d0d1b5dc11059d8a9ffe54bcb14At this point, only one sys_id is present in the glide list.
Later execution:
Circular list: ba91ab5587b3b6581e95c8070cbb356f,3f5539c187bbf6181e95c8070cbb3514
Application user: ba91ab5587b3b6581e95c8070cbb356f
Array: ba91ab5587b3b6581e95c8070cbb356f,3f5539c187bbf6181e95c8070cbb3514Now the glide list is correctly populated with multiple values
🔹 Problem
During the first execution, the glide list is incomplete → validation fails
During the second execution, the data is correct → but record is already aborted
🔹 Additional Info
Business Rule is running Before Insert
Workspace is being used
Is there a reliable way to ensure validation runs only when the glide list is fully populated?
Any guidance or best practice suggestions would be really helpful.
Thanks in advance!
