@@ -258,24 +258,32 @@ export class BaseVariableResolver {
258
258
const root = getRootElement ( bo ) ;
259
259
const allVariables = await this . getProcessVariables ( root ) ;
260
260
261
- // keep only unique variables based on name property
262
- const uniqueVariables = uniqueBy ( 'name' , allVariables . reverse ( ) ) ;
263
-
264
261
// (1) get variables for given scope
265
- var scopeVariables = uniqueVariables . filter ( function ( variable ) {
262
+ var scopeVariables = allVariables . filter ( function ( variable ) {
266
263
return variable . scope . id === bo . id ;
267
264
} ) ;
268
265
269
266
// (2) get variables for parent scopes
270
267
var parents = getParents ( bo ) ;
271
268
272
- var parentsScopeVariables = uniqueVariables . filter ( function ( variable ) {
269
+ var parentsScopeVariables = allVariables . filter ( function ( variable ) {
273
270
return parents . find ( function ( parent ) {
274
271
return parent . id === variable . scope . id ;
275
272
} ) ;
276
273
} ) ;
277
274
278
- return [ ...scopeVariables , ...parentsScopeVariables ] ;
275
+ const reversedVariables = [ ...scopeVariables , ...parentsScopeVariables ] . reverse ( ) ;
276
+
277
+ return reversedVariables . filter ( variable => {
278
+
279
+ // if external variable, keep
280
+ if ( variable . provider . find ( extractor => extractor !== this . _baseExtractor ) ) {
281
+ return true ;
282
+ }
283
+
284
+ // if not external, keep only if first of its name
285
+ return reversedVariables . find ( v => v . name === variable . name ) === variable ;
286
+ } ) ;
279
287
}
280
288
}
281
289
0 commit comments