From 7d79e3511a7370085339ffc49ebff4f28d4495ee Mon Sep 17 00:00:00 2001 From: Abdul Ahad Date: Mon, 23 Dec 2024 23:20:05 +0500 Subject: [PATCH] fix: same resultVariable and output names filter only output names --- lib/zeebe/VariableResolver.js | 9 +++++++-- lib/zeebe/util/feelUtility.js | 7 ++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/zeebe/VariableResolver.js b/lib/zeebe/VariableResolver.js index 5a032a6..cfe9dbd 100644 --- a/lib/zeebe/VariableResolver.js +++ b/lib/zeebe/VariableResolver.js @@ -40,8 +40,7 @@ export default class ZeebeVariableResolver extends BaseVariableResolver { } const namesToFilter = getElementNamesToRemove(moddleElement, inputOutput); - - return variables.filter(v => { + const filteredVariables = variables.filter(v=> { // Keep all variables that are also defined in other elements if (v.origin.length > 1 || v.origin[0] !== bo) { @@ -59,6 +58,12 @@ export default class ZeebeVariableResolver extends BaseVariableResolver { // Filter all pre-defined variables return !namesToFilter.includes(v.name); }); + + // keep only unique names + const uniqueVariables = new Map(); + filteredVariables.forEach(v => uniqueVariables.set(v.name, v)); + + return Array.from(uniqueVariables.values()); } /** diff --git a/lib/zeebe/util/feelUtility.js b/lib/zeebe/util/feelUtility.js index ebbbb92..688ab2b 100644 --- a/lib/zeebe/util/feelUtility.js +++ b/lib/zeebe/util/feelUtility.js @@ -159,7 +159,12 @@ export function getResultContext(expression, variables = {}) { * @returns {{ expression: String, unresolved: Array }}} */ function getExpressionDetails(variable, origin) { - const expression = getScriptExpression(variable, origin) || getIoExpression(variable, origin); + + // if variable scope is parent scope, first check IoExpression and then ScriptExpression + // if variable is local scope (origin), first check ScriptExpression and then IoExpression + const expression = variable.scope !== origin + ? getIoExpression(variable, origin) || getScriptExpression(variable, origin) + : getScriptExpression(variable, origin) || getIoExpression(variable, origin); if (!expression) { return;