From ac8bb95e035d0aeec9446b03cde835ceb992acb7 Mon Sep 17 00:00:00 2001 From: Tony Valle <79843014+superskip@users.noreply.github.com> Date: Fri, 15 Sep 2023 12:09:43 +0200 Subject: [PATCH] fix: [DHIS2-15844] allow multiple occurences of d2:hasValue in a single expression (#1863) --- d2-tracker/dhis2.angular.services.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/d2-tracker/dhis2.angular.services.js b/d2-tracker/dhis2.angular.services.js index 48888ea93..ab0570777 100644 --- a/d2-tracker/dhis2.angular.services.js +++ b/d2-tracker/dhis2.angular.services.js @@ -1841,7 +1841,7 @@ var d2Services = angular.module('d2Services', ['ngResource']) //d2:hasValue('variableName') to avoid the further replacement, and make sure the correct input is fed into d2:hasValue. var avoidReplacementFunctions = ['d2:hasValue','d2:lastEventDate', 'd2:count', 'd2:countIfZeroPos', 'd2:countIfValue']; avoidReplacementFunctions.forEach(avoidReplaceFunction => { - expression = expression.replace( new RegExp("(" + avoidReplaceFunction + "\\() *[A#CV]\\{([\\w \\-\\_\\.]+)\\}(.*)\\)" ), "$1'$2'$3\)"); + expression = expression.replaceAll( new RegExp("(" + avoidReplaceFunction + "\\() *[A#CV]\\{([\\w \\-\\_\\.]+)\\}", 'g'), "$1'$2'"); }); //Check if the expression contains program rule variables at all(any curly braces):