Nested Loops and String Comparisons in a Microflow

0
for Recipe_Ingredient as RI: mybool = False for Pantry_Ingredient as PI: IF PI.Name == RI.Name: mybool = true break I want to translate the following pseudo-code to Mendix. I have the following Microflow: I just need to write the IF in the decision in XPath and then the boolean but I don’t know how to do string comparisons.
asked
2 answers
0

Camila,

For string comparisons you can follow the Mendix String Functions

However, I think you may have some issues with your domain model to accomplish what you are trying to do
Are you trying to see if the ingredients in your recipe are also available in the pantry? There are a few ways to do this,

You shold be able to do a complex retrieve where you retrieve the recipe, the pantry, and then use XPath to retrieve a list of ingredients where [$Ingredient_Pantry = $Pantry][$Ingredient_Recipe = $Recipe]
Your domain model would bode well to look something like this:

answered
0

Camila,

If you want all the ingredients for the Recipe (input parameter) that exist in your Pantry (you will need to retrieve a single pantry)
You should be able to retrieve these Ingredients from database with the XPath:


I see in your microflow you are retrieving a list of what you named “RecipeIngredientList” however you are retrieving a List of Recipe instead if Ingredient. Same with your “PantryIngredientList”, this is a list of Pantrys and not ingredients.
I’m not sure I understand what your goal is, but if you are passing in Recipe as your input parameter, I would think you need to “look in the pantry to see if you can make this recipe”. In this case, you need to somehow end up with a single pantry object to compare your recipe to. Maybe assigning a pantry to a user will help you simplify this process.

answered