From aca8bfbda4196789f5148a8c0baab75b4b3683e7 Mon Sep 17 00:00:00 2001 From: Tony Valle <79843014+superskip@users.noreply.github.com> Date: Wed, 8 Nov 2023 19:21:56 +0100 Subject: [PATCH] fix: [DHIS2-14190] make sure option is non-`null` (#1885) --- d2-tracker/dhis2.angular.services.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/d2-tracker/dhis2.angular.services.js b/d2-tracker/dhis2.angular.services.js index ab0570777..0a3a209f8 100644 --- a/d2-tracker/dhis2.angular.services.js +++ b/d2-tracker/dhis2.angular.services.js @@ -451,12 +451,12 @@ var d2Services = angular.module('d2Services', ['ngResource']) const keyString = String(key); // is key a name? - const option = options.find(option => keyString === option.displayName); + const option = options.find(option => option && keyString === option.displayName); if (option) { return option.code; } // is key a code? - if (options.find(option => keyString === option.code)) { + if (options.find(option => option && keyString === option.code)) { return key; } // not a part of the option set @@ -471,12 +471,12 @@ var d2Services = angular.module('d2Services', ['ngResource']) const keyString = String(key); // is key a code? - const option = options.find(option => keyString === option.code); + const option = options.find(option => option && keyString === option.code); if (option) { return option.displayName; } // is key a name? - if (options.find(option => keyString === option.displayName)) { + if (options.find(option => option && keyString === option.displayName)) { return key; } // not a part of the option set