Many to many: Display Data in Block

Hi Community, 

I´m trapped in a dead end which I am trying to get out of since one week now. I hope someone here can help me. 

I created an example I attached which describes what I am trying to do.

In the example I create houses. These houses have flats and the flats have rooms. In every room is one or more equipment. As the flats are basically the same in all houses I created templates for them. The content of a flat template can be copied into a flat. So basically it is 

House 1 - n Flats

Flat 1 - n Room

Room n - n Equipment

Setting this structure up is quite straight forward (I guess) but what I want to do is to give the user the chance to edit equipment on flat level. 

I created a block for it. But no matter what I do, the block is empty every time. 

It would be great if someone finds a minute or two to look over my code and give me a hind! 

Thanks 

Tobi

*I created an example for this post so the code might not be best pratice (e.g. server actions or naming)




Hi, friend. 

If I understand well, you should edit the EquipmentBlock and insert GetEquipmentRoomByRoomId and add the option to insert new equipmentes there. 

I just can't understand some relationships you made between Room, Flat and FlatTemplate. Is that correct? The way you did, a same room could be linked to many different flats in the FlatRoom entity, which is not you told above.

I think that Flat could be many to many with Rooms and Rooms could have Templates (which could be an static). Keep Rooms many to many with equipments.

What do you think? I really don't know if my idea fits to your needs, but i'm suggesting.


Hi BigSlikTobi,


After analyzing your code, I observed that as per the requirement, the defined data model is not up to the mark. Adding to that some of the developed logic were incorrect. I tried to do some code changes in your application solution file (a bit) as per my business understanding after referring the mentioned objective. 

Hope this small contribution will help you in some way :)


Check this: Example Demo App

PFA - Includes the .oml solution


Regards,

Benjith Sam 

Hi! 

Here is a 3rd suggestion for your data. 

You have the room linked to the template and the FlatRoom linked to the a FlatTemplateRoom 

Hope this helps. 

Graça 

Hi,

Eveyone gave their opinions, let me give also mine ;)

I suggest a very simple data model:

 

You use your own Flat-Room-EquipmentRoom to store information about the templates.
This makes life much easier.

Attached is a demo (changed from your example). Very poor, but enough to demonstrate the use.

You can create flats (and mark them as templates or not) and rooms into flats, and create equipments and add to rooms.

You can then create a house and add new flats (and create everything) or add flats based on templates, that will create everything from the template chosen.

Hope this helps.

Cheers.

Hi all! 

thank you very much for your help! 

I created this house, room, flat thing especially for this discussion so it might look a bit unlogical. The real use case is truck (House), swap-body (Flat), loading category (Room) and loading equipment (Equipment). 

The issue I have is not the template. This works fine. The issue is that I cannot filter the right equipments to the right house. 

Let´s say I have one house with 2 flats. Then I want the block to show me every room with all it´s equipment (within the flats within the house). So going with @Benjith Sams example the flat detail needs to be editable within the house detail view.

The original case would be: I have one truck with two swap-bodies. Swap-body 1 has the loading categories liquids and dry chemicals (Swap-body 2 something else). The load category liquids has barrels and bins as equipment and the LC dry chemicals has sacks as equipment. I would now like to edit the amount of barrels, bins and sacks within swap-body 1 directly within the truck. 

(btw: never load liquids and dry chemicals within the same swap-body ;) ) 

Any guesses? 

Have a great day & stay healthy! 

Tobias 

Hi again !

Have you tried this?

Maria da Graça Peixoto wrote:

Hi again !

Have you tried this?


Hi, 

in this case it shows all Flats with all Equipments in the block. Which filters would you use? 

You can filter by which field you need, may be the house Id if you want to see all the equipment in a house or the HouseFlat Id  if you want only the equipment from a flat

Hi all,

I just wanted to update you that I solved the issue. I need to update the FlatRoom within the house detail and assign the box to it. Having this done the HoseFlat needs to be updated with this information.

It works so it is good! But the code turns pretty heavy now. I will try to implement another, leaner approach like Eduardos.

Thank you all for your help, I had never solve this without it!

Tobias