Skip to content

Commit

Permalink
fix: same resultVariable and output names filter only output names
Browse files Browse the repository at this point in the history
  • Loading branch information
abdul99ahad committed Jan 8, 2025
1 parent 9c4d46b commit 0c3bfaa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
8 changes: 6 additions & 2 deletions lib/base/VariableResolver.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getBusinessObject, is } from 'bpmn-js/lib/util/ModelUtil';
import CachedValue from './util/CachedValue';
import { getParents, getScope } from './util/scopeUtil';
import { uniqueBy } from 'min-dash';

/**
* @typedef {Object} AdditionalVariable
Expand Down Expand Up @@ -257,15 +258,18 @@ export class BaseVariableResolver {
const root = getRootElement(bo);
const allVariables = await this.getProcessVariables(root);

// keep only unique variables based on name property
const uniqueVariables = uniqueBy('name',allVariables.reverse());

// (1) get variables for given scope
var scopeVariables = allVariables.filter(function(variable) {
var scopeVariables = uniqueVariables.filter(function(variable) {
return variable.scope.id === bo.id;
});

// (2) get variables for parent scopes
var parents = getParents(bo);

var parentsScopeVariables = allVariables.filter(function(variable) {
var parentsScopeVariables = uniqueVariables.filter(function(variable) {
return parents.find(function(parent) {
return parent.id === variable.scope.id;
});
Expand Down
4 changes: 1 addition & 3 deletions lib/zeebe/VariableResolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
} from 'bpmn-js/lib/util/ModelUtil';
import { getInputOutput } from '../base/util/ExtensionElementsUtil';


const HIGH_PRIORITY = 2000;

/**
Expand Down Expand Up @@ -40,8 +39,7 @@ export default class ZeebeVariableResolver extends BaseVariableResolver {
}

const namesToFilter = getElementNamesToRemove(moddleElement, inputOutput);

return variables.filter(v => {
return variables.filter(v=> {

// Keep all variables that are also defined in other elements
if (v.origin.length > 1 || v.origin[0] !== bo) {
Expand Down
7 changes: 6 additions & 1 deletion lib/zeebe/util/feelUtility.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,12 @@ export function getResultContext(expression, variables = {}) {
* @returns {{ expression: String, unresolved: Array<String> }}}
*/
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;
Expand Down

0 comments on commit 0c3bfaa

Please sign in to comment.