Microflow: Accessing first item of a list

I have a list in a microflow. I would like to pass the first and second items of that list as parameters to another microflow. In the argument for that microflow I can find the $list variable, but I am not sure how to get one specific item from it.
3 answers

I'm afraid you can't do this in a microflow yet. A workaround is retrieving a single item instead of a list (sorted in the same way as your list retrieval of course) and using that. Or you can use a Java action to do it if performance is an issue.

If you don't actually need the object as a variable but only have to perform a check or something similar, you can just start iterating over the list and breaking from the loop after you checked the first object.


What I do usually is loop the list, do your logic, break. In that case the logic will only be executed for the first item.


Perhaps, as a crude workaround, you could add an attribute to the Entity that you're retrieving which is a simple check boolean that defaults to false. In the first microflow, you loop over the list, using an integer variable that starts at 0. You add 1 to this variable for each iteration. If you check at the start of the loop if the variable => 2, you can break off the loop after two iterations.

Then you can set the boolean to true inside the loop. This means you have now 'marked' the first two objects in the list.

You can then retrieve those two items with an xpath (boolean=true()).