Combine multiple relation fields into one views cell as clickable entities (no polymorphism)

I have often the need to show many relationships of the same entity in a view.

For example, I have a Conversion Log field that relates to every database. That while each Conversion Log relates to only one database, so only one relation column is occupied per Conversion Log.

This currently leads to a view with many many columns, and of course we want to visually include all relationships into the same column. This is therefore not a polymorphism request, but a feature to display mutliple fields as one cell in the view.

I can imagine that this is pretty easy when the relationship is a to-one relation, so that there is only one related database per views item, not a collection. This could be a cell where the different fields are stacked vertically in the same row.

Please let me know if something like this is already thought of or considered.
Thanks!

If all the fields are named the same (“Conversion Log”, in your example) then they should all be shown in the same column already.

If they’re all named different things, then you can use a formula with a bunch of If statements to display whichever relationship is has been populated, or you can use the “Join” function.

Using Ifs:

If(IsEmpty(ColumnA),
    If(IsEmpty(ColumnB),
        If(IsEmpty(ColumnC),
            ColumnD, ColumnC)
        ColumnC),
    ColumnB)

Using Join:

ColumnA.join(Name, ", ") + ColumnB.join(Name, ", ") + ColumnC.join(Name, ", ") + ColumnD.join(Name, ", ")

Best case scenario would be a Union function if it ever gets built.

2 Likes

The fields I want to combine are relationship fields (one-to-one) with names that correspond with the related entity, and all related entities have different names. Fields of the same database cannot have the same names, so I cannot use the automatic column unification feature in views.

The formula can’t be saved and complains about different data types. But the data type for both is simply Entity, so why does it complain?

chrome_UrteABG7wY

It doesn’t allow you to use different entity types.
You can do something like this to get just the text.

If(IsEmpty(Page), Note.Name, Page.Name)
1 Like

Yeah, sorry @Yuri_BC I didn’t realize they were different types of Data. @matth’s suggestion would definitely work if you just need the name.

1 Like