Combine 2 unrelated entities into a single List/Gallery

Hello,

I am attempting to create a single list/gallery consisting of records from different entities, for instance "Signs" and "Vehicles", each with their own set of attributes i would also like to be able to search on. Furthermore, I would like to sort my records by a parent location(so within each location would be a mix of asset types. Upon clicking any gallery item, i would like to be taken to a popup window/detail screen related to that specific asset type/entity. My initial though was to create a list of locations, and within each list item, include gallery/list for each of the asset types, but i do not believe you can insert a list within a list in outsystems. What would be the best way to implement this?

Thanks

Hi Sten,

The platform does not allow to put a list inside another list, so if you want to do so, the inner list has to be in a web block, receiving the parent ID from the outer list as an input parameter. This input parameter would then be used to filter the data retrieved in the web block's Preparation.

That said, you'd end up having a list of web blocks in your screen and each web block would have a list inside it.

Hope it helps.


Cheers!

Hello Sten,

From your description, it does not appear that there is a clear parent child relationship. 

A thought could be to create a structure with the related fields of both the Signs & Vehicles and populate such a list which you can bind to a gallery. Also when you click on an item, show the details in a block which could have lists. 

Also do check out the screen templates for lists for inspiration. 

Hope this helps !!!


Hi Sten,

Your approach of displaying a ListRecords having as Source Record List a List of Location seems sensible. Given the restriction mentioned by Ricardo, you would have to implement your Gallery of Signs/Vehicles/etc inside a Web Block, passing it the Id of the Location you would want to display. This Web Block (I will call it LocationGallery) would need to fetch the right records in its Preparation (filtered by LocationId).

In order to display each individual Sign/Vehicle/etc on your LocationGallery, you need a single Gallery, with a List Records inside, so you have to somehow get all your Location's content in one single List. This List needs to be obtained in the Preparation, and creating it could follow different approaches:

  • A simpler to think about and maintain "create your Structure with common fields" like Amal suggests, where you fetch the Entities individually and then manually iterate both lists and merge them into a final List (you may be able to use ListAppendAll and mappings to avoid having to do it explicitly) - but you need to come up with the Structure yourself and likely not all fields will be "common" to all entities, or;
  • What I believe would be a more optimised way would be "create a single Aggregate with the two (or more) Entities", where you Join them all together With or Without, with join condition of False. The resulting List should be a record with all Entities, where only one has data.* You can then create a Calculated Attribute that gets the Image from the one record that has Id <> NullIdentifier() and Group by that Calculated Attribute along with all the Ids of the Entities (again, only one will have a meaningful value per record) - the main advantage here is the database does all the grunt work.
    * Haven't tested this out, may need a bit more thinking...

Simplest solution afterwards would probably be having different Web Blocks to display the different types of entities (Image and specific label plus showing the correct information in a popup/link to correct details page).

Searching/Filtering can be achieved by adding filters to the Aggregate(s) in the LocationGallery Web Block's Preparation above.


Amal Raj wrote:

Hello Sten,

From your description, it does not appear that there is a clear parent child relationship. 

A thought could be to create a structure with the related fields of both the Signs & Vehicles and populate such a list which you can bind to a gallery. Also when you click on an item, show the details in a block which could have lists. 

Also do check out the screen templates for lists for inspiration. 

Hope this helps !!!


Hi Amal,

The parent relationship i was referring to was that all assets have a parent location. I also trying to have a global search, so if i were to use webblocks filled with gallerys, could the search act on these webblocks? im not entirely clear on the structure approach. So far i have not had much experience with structures aside from creating structure attributes... any chance you could provide a very simply OML showcasing this route?

Thanks so much!