Operation for the last element in the list

0
Hi guys,  Can someone tell me how to pick the last element of the list? I know about 'Head' option , but I need the last element exactly, because after every iteration I get increased number of element in the list and I need every time exactly that last element. Best regards, Aleksandar
asked
5 answers
1

Aleksander,

If you are in a loop in a microflow and add 1 item to your list each iteration, you could create 2 Lists.  If they are List_Old (before the addition of the item) and List_New (after the addition of the item), you could use a List Operation activity and Subtract List_Old from List_New.  After you do this subtraction, set List_Old = List_New so it is ready for the next iteration.

Hope that helps,

Mike

answered
1

Could you share the microflow in which you have these iterations? Maybe it helps to suggest ideas.

answered
1

Alexsander,

I got curious about this, so I did some testing.

I haven't been able to see a pattern in the order the Sessions are returned in the List.  I thought it might be oldest first or oldest last, but that is not the case from my testing.  This made me wonder what your use case is for this - maybe sharing the use case would help with some ideas for resolving your question.

Mike

answered
0

Hi Aleksandar,

No way to do this with a regular mendix action as far as I know.

There used to be a function in the community commons but I can't seem to remember the name. Your best approach IOP is to write your own java action to do this.

-Andrej

PS: If your list is sorted, perhaps you can sort it in the reverse order and then get the Head element

answered
0

I need as a one user role to see as another user role(to use his account or credentials and to see as him). For example as administrator (but it could be any other user role not only administrator as in my case) I want to see the things as a specific user role (for example user) in order to help him with the current situation that he has been stuck(he could have some problems and want to help him without log out the application). I made a list retrieving all users from the database, and put button in every row. As administrator when I click on the button , I put that user in the current session as a non - persistable entity and further on use his account for my tasks. But problem started when I click on another users from the list because mendix put that new non-persistable user on the last place in the session, and I can't select him because number of  elements of my current session are changing when I'm clicking on the other buttons. I solve that on the other way, but without option to select the last user from the session. 

Best regards,

Aleksandar

answered