Web Screen source from different aggregates

I have an address file that can hold addresses from 2 different sources Company addresses and people addresses. I have separate company and people files with many-to-many relationships between people and address as well as between company and address.

As I said I have only 1 address file and I want only 1 address maintenance screen.

My problem is in the preparation for the screen when I read any existing addresses using the appropriate many-to-many relationship I finish with 2 aggregates. But I cant find a way to populate the address maintenance form with whichever one I want. If i'm running the address form from the people screen I want the people addresses and same for company.

So how do the two types of addresses differ? Are they using the same entity or two different entities? If they are the same entity, it would be fairly easy to handle, just create a local variable of that entity type that the form is relating to, and then assign that local variable whichever you are trying to view in the preparation. (there is also possibly a way you could handle the right one to get with a complexly filtered aggregate, but this might be more straight forward)

If you are trying to show two different kinds of entity in one form, this gets a lot more complicated. You could create a Structure that has elements of both of the addresses, and then a Boolean toggle that tells what kind it is, so that you can use the appropriate Update action when you want to save the form, as well as showing or hiding the appropriate fields. You then would again set this local Structure in your preparation. However, if they are two different entities it might make sense to have two different pages as well.

Do either of those solutions make sense? If not this is a little hard to follow, would you be able to provide an OML?

So how do the two types of addresses differ? Are they using the same entity or two different entities? If they are the same entity, it would be fairly easy to handle, just create a local variable of that entity type that the form is relating to, and then assign that local variable whichever you are trying to view in the preparation. (there is also possibly a way you could handle the right one to get with a complexly filtered aggregate, but this might be more straight forward)

If you are trying to show two different kinds of entity in one form, this gets a lot more complicated. You could create a Structure that has elements of both of the addresses, and then a Boolean toggle that tells what kind it is, so that you can use the appropriate Update action when you want to save the form, as well as showing or hiding the appropriate fields. You then would again set this local Structure in your preparation. However, if they are two different entities it might make sense to have two different pages as well.

Do either of those solutions make sense? If not this is a little hard to follow, would you be able to provide an OML?

-Jordan

Hello Jordan,

Thanks for the quick reply.

There is only 1 address entity. I have written a preparation (using a variable as you suggested) to use the appropriate many-to-many (and through a join, to the relevant address records). But that leaves me with 2 aggregates - one created by using the many-to-many from the company and the other from the many-to-many from the people.

No oml but here are the file layouts

Company Entity

id

name

other attributes

People Entity

id

name

other attributes

Address Entity

id

Add1

other attributes

CompanyAddress Entity

id

CompanyId

AddressId

PeopleAddress Entity

id

PeopleId

AddressId

In the preparation, I have an IF widget that checks an input parameter to see if it should use the CompanyAddress entity or the PeopleAddress Entity. That requires 2 different aggregates (each aggregate joins to the address file) and so produces 2 different lists. My problem is that I want to have 1 address maintenance form but to do that I need a source record list. In this case the source list depends on the input parameter and so I don't know how to code it.

If this is the case then, instead of passing the CompanyId or PeopleId, you should pass an AddressId and your Aggregate is simply fetching the right Address... on the page that links to this Address Details page you will have to fetch the correct AddressId by querying the correct Junction Entity.

If it's not, and you are trying to create an Address List page, there is still the question, do you need to distinguish between the two types of addresses? or can you just show all of them?

If you need to show either company addresses or person addresses but not both then:

Create a Local Variable of type List of Address (I'll call it Addresses).

In the Preparation, after each of the Aggregates, assign the output of the Aggregate to the Addresses variable (you will likely be asked to map the contents of the two lists, as their elements are of different data types).

In your screen, make sure you bind your Source Record List to the Addresses variable, this way, from the List/TableRecords perspective, it doesn't really matter how you got your Address list.

If you can show both at the same time, then it's just a regular List page, you can create one by just dragging and dropping the Address entity onto a UI Flow canvas...

If this is the case then, instead of passing the CompanyId or PeopleId, you should pass an AddressId and your Aggregate is simply fetching the right Address... on the page that links to this Address Details page you will have to fetch the correct AddressId by querying the correct Junction Entity.

If it's not, and you are trying to create an Address List page, there is still the question, do you need to distinguish between the two types of addresses? or can you just show all of them?

If you need to show either company addresses or person addresses but not both then:

Create a Local Variable of type List of Address (I'll call it Addresses).

In the Preparation, after each of the Aggregates, assign the output of the Aggregate to the Addresses variable (you will likely be asked to map the contents of the two lists, as their elements are of different data types).

In your screen, make sure you bind your Source Record List to the Addresses variable, this way, from the List/TableRecords perspective, it doesn't really matter how you got your Address list.

If you can show both at the same time, then it's just a regular List page, you can create one by just dragging and dropping the Address entity onto a UI Flow canvas...

Hope this helps!

Thanks to everybody who replied. Jorge's idea of assigning the aggregate output to a variable was the answer.