Value change for the same variable within variable

0
Hi Members,I see really strange issue in one of the micrflow service. I am creating variable outside the loop and change it inside the loop. Recently added an activity to change the same variable in the same variable in the lopp. It worked for some days but then it is not working at all. and when i re deployed the change it worked.So i am wondering if I my latest change made this isue. Has some also faced it earler?RegardsAbhi
asked
1 answers
0

Hi Abhinay,

From the screenshot, I don't think the problem is simply "changing the same variable twice". That's a perfectly valid pattern in a microflow.

For example:


Plain Text



$Rounding = 0

Loop

Change $Rounding = $Rounding + 1

Change $Rounding = $Rounding * 10

End Loop

Mendix will execute the activities sequentially and use the latest value of the variable.

What concerns me more is this statement:

It worked for some days but then it is not working at all. After redeploying it worked again.

That sounds less like a variable issue and more like:

  • A changed deployment was not actually running.
  • The microflow is being called concurrently by multiple processes.
  • The loop data changed and is causing different results.
  • One of the expressions is evaluating differently than expected.

To troubleshoot, I'd recommend:

  1. Add log messages before and after each Change Variable activity:


Plain Text



Before Change 1: {$Rounding}

After Change 1: {$Rounding}

Before Change 2: {$Rounding}

After Change 2: {$Rounding}

  1. Verify the expressions on both Change Variable activities. From the screenshot we can't see whether they use the same expression or different expressions.
  2. Check whether the microflow is running in parallel from multiple requests, especially if $Rounding is later stored in an object.
  3. If redeployment fixed it, compare the runtime logs before and after deployment. I've rarely seen a local cache/deployment issue, but the variable logic itself is deterministic and should behave the same every execution.

In short, changing the same variable multiple times inside a loop is supported and should not randomly stop working. I'd focus on the expressions used in those activities and add logging to confirm the value after each step. That will usually reveal whether the issue is in the calculation, the loop data, or somewhere later in the microflow.


answered