How to retrieve a user-specific object that inherits from Administration.Account and use it on a different page?

1
Hi all, I'm relatively new to Mendix and it pains me to say that I've been stuck on this for more than 10 hours, so I really hope one of you could help me out. Many thanks in advance!   For a school project, I'm building a website where customers and restaurants can sign up and log in to buy and sell food! I've managed to set up the sign up system using microflows, where upon creation of an account, depending on whether the user selected they were a customer or restaurant they are assigned the corresponding user role. An object of the RestaurantAccount entity is created, which has Administration.Account as its generalization. Logging in happens via the standard Login Id Text Box, Password Text Box and Login Button. After logging in as a restaurant, you get taken to a user specific HomeRestaurant page, from where I'd like the restaurant to be able to navigate to a Menu page to see its own menu and edit it (and obviously only its own menu, not that of other restaurants). However, when I tried to simply use a show page button, it gave me the following error: "The selected page 'Menu' expects an object of type 'RestaurantAccount', which is not available here." Besides a list view with MenuItem objects (that are associated with a RestaurantAccount object) on the Menu page, there's also a Go Live/Go Offline button that changes the value of the boolean IsLive attribute of the RestaurantAccount object.   So, I think, after logging in with a certain account Mendix doesn't automatically know which RestaurantAccount object it's dealing with and therefore doesn't know which RestaurantAccount object to send over to the Menu page. To fix this, I wanted to trigger a Microflow that retrieves the current user's Account object (I've done that exactly as suggested in this documentation: https://docs.mendix.com/refguide/retrieving-current-user-with-a-microflow/), but at this point I'm stuck, since I don't know how to go from this Account object to its corresponding RestaurantAccount object, and how to pass that to a page.    Any help would be massively appreciated, and again many thanks in advance for the help!   P.S. I've attached some screenshots of what parts of my app look like. Feel free to ask for more images or explanations if I haven't been able to make clear enough how my program currently works, how I want it to work and what my problems are!
asked
3 answers
1

To get a specific specialization from a generalization (in your case, from account), you can use an "inheritance split" (called an object type decision in the modeler). Instead of using the yellow decision block, grab the green one and select your "Account" object. You can now create separate logic flows for each of the options, in your caes, a CustomerAccount or RestaurantAccount. After the split, use a "Cast" option to actually get the specialized object. 

 

Here is an example I pulled off google (not all of it follows best practices, but the relevant part is the green split and the cast):

1_aRo6Bh4xKSBLl7o4ukz7Bg.png

answered
0

This is what my microflow currently looks like, Eline.

Mendix5.png

answered
0

Hey Casper Soede

you can use object type decision and cast activity in a microflow to get the inherited object.

answered