Redefine an object variable in a Microflow - Mendix Forum

Redefine an object variable in a Microflow


In a Microflow it it common to work with variables.  Variables may be created and modified.

However it is not possible to do the same with object variables.

Suppose I need to retrieve an object of EntityA.  The retrieval depends on some condition.

The Microflow looks like

The retrieved object in the upper swimlane must have a different name then the one in the bottom swimlane (ObjectA end ObjectB)

So it is not possible to do something with the result.

Some workarounds:

duplicate the code for “do something”

That would result in

But the code for “do something” must be duplicated.  Not a good way of working.

The “do something” could be encapsulated into a Microflow.  This may lead to having too many small Microflows that have no real meaning.

It would be much easier if an object variable could be created and changed.

2 answers

I agree with the workarounds.

@Mendix: is there a good reason for not having the possibility to create a variable of type “object reference” and then the possibility for a “change variable” action ?  This can’t be that difficult.


there are some other workarounds that don't require duplicate code. Create a submicroflow wich handles the retrieve, and returns the object.

Or you could create a list, add the retrieved object to that list, and after the merge, use the Head list operation.

But yeah, would be nice if you could do this directly...