From 6a08214ca3263b495bdb143bb26ee932b14a7fb6 Mon Sep 17 00:00:00 2001 From: Marty Pradere Date: Tue, 8 Sep 2026 05:54:31 -0600 Subject: [PATCH] Add a shared helper for lookup field case normalization Nine trigger scripts across the compliance and SSU modules had each copied this loop verbatim. The LookupValidationHelper is passed in rather than created internally so callers keep it at script scope, where its cache of allowable values is read once per batch instead of once per row. --- LDK/resources/scripts/ldk/Utils.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/LDK/resources/scripts/ldk/Utils.js b/LDK/resources/scripts/ldk/Utils.js index e67bc056..00cd804f 100644 --- a/LDK/resources/scripts/ldk/Utils.js +++ b/LDK/resources/scripts/ldk/Utils.js @@ -73,6 +73,25 @@ LDK.Server.Utils = new function(){ //normalize to a javascript date object date = new Date(date.getTime()); return new Date(date.getFullYear(), date.getMonth(), date.getDate()); + }, + + /** + * Replaces each named field's value with the case-normalized value from its lookup target, adding an error for any value the target does not contain. + * The helper must be created at script scope: it caches each target's allowable values per instance, so creating one per call would re-read the target table for every row. + */ + normalizeLookupFields: function(helper, row, errors, lookupFields){ + for (var i=0;i