Problem with boolean variable in microflow

0
Hi, I recently started learning how Mendix works and I have a question. I have a microflow that should check some form entries to see if the user have filled every input necessary or not. I created a boolean variable, initialized as true, at the start of the microflow and I check every input if it’s filled or not. If it is, the variable stays true, otherwise a message will be showed and the variable will be set as false. (check the image below to see the microflow). The problem is that, if i don’t fill any input object, the variable ultimately will be true (and it should be false, obviously) and checking with breakpoints, I saw that it alternately turns true and false every other time. I think that the logic of the flow is good but the results is not what it should be. Ideas?
asked
7 answers
3

The real issue is when you are using the expression, it is returning the result of the expression as the value of the variable. So, when the variable is actually false, it sets the value of the variable as true (the return value of the expression)

answered
0

I think the flow looks right.

The Create action should initialise the boolean to true. Then any of the changes in your decision splits should set it to false if there was a problem. Finally at the end you check the boolean, and if it’s false you stop, and true you carry on. 

Is this how you have it setup?

How are you checking the values in your decision splits? Can you give some examples?

answered
0

Yes, just like you said.

The variable is set to true at the beginning and changed to false if the forms are not filled in. At the end, if the variable is true, the object will be commited, if not, the flow will end with no actions.

I’m checking the values with this rule called “String_NotEmpty”:

$InputToCheck != empty
and
trim($InputToCheck)!= ''
 

 

answered
0

Here is the last step of the microflow.

 

answered
0

This is where I check if the user has filled the “Name” field. I posted the “String_NotEmpty” rule in a previous comment.

answered
0

This is the block where I change the variable.

I noticed that the first one sets it as false like it should, but after the second one, it turns back to true, then after the third one it turns back to true. This microflow only works if there is an odd number of fields to check, If it’s even it doesn’t work. 

I actually copied this microflow from the “Crash Course” course from the Mendix Academy and that has the same problem as well. 

answered
0

Thanks guys, you solved it! I just have to write “false” in the value window.

I’m so dumb.

Thnak you so much!

answered