Company, Product, Order en OrderLine. Dropdown on OderItem shows all products

Hello,

At the moment I'm trying to get something to work in OutSystems 11.
I have 4 entities called companie, product, order and orderline.

What I'm trying to do is to display the products of the company when adding a new OrderLine. The problem is that I always get all the products. No matter what CompanyId the product has. 

I've created the Order en OrderDetail screen by right mouse click -> Create List Screen and Create Detail Screen. In my Order Detail screen I've dragged the OrderLine and it has created a nice list. 

But when I click add new OrderLine, all products are shown. Not only the products that has the same CompanyId as the order. 

I can't find a filter or something to make it work.

Datamodel:(OrderItem is renamed to OrderLine)

Product Overview

Wrong populated dropdown

MainFlow:

Hi, there.

I think you should take a look on your db model first. This multiple reference can cause inconsistences in you db. You have multiple cyclic references.

If I understand well, you should have:

1) Companies one to many with Products

2) User one to many with Orders

3) OrderLine making many to many relationship between order and product.

What do you think?


Best regards.


Lenon Manhães wrote:

Hi, there.

I think you should take a look on your db model again. This multiple reference can cause inconsistences in you db. You have multiple cyclic references.

If I understand well, you should have:

1) Companies one to many with Products

2) User one to many with Orders

3) OrderLine making many to many relationship between order and product.

What do you think?


Best regards.


First, thanks for you answer!

I agree, but I need also to store the added OrderLine by user.
So every orderline should have a CreatedBy I thougt. I need the information about who created the Order and who added OrderLines

So when I take a look at the data model I don't see something that is Wrong

1) Company has many Products and many Orders

2) Order has many OrderLines

3) Products has many OrderLines

4) OrderLine has 1 User, Product and Order

5) User has many Orders and Orderline


It is already 0:54 here, so I it is possible that I'm missing something.

Then I invite you to take a better look tomorow morning with fresh mind.

The way I told you, a User will have an Order and the Orders will have OrderLines. That's why we call relational. Undirectly, every OrderLine will be linked to an User.

The way you did, you could have a User with many Orders with many OrderLines but OrderLines has its own UserId. That is a duplicated reference and can cause problem. Otherwise, Users could have OrderLines without Orders, whats breaks the concept of many to many of OrderLines.

The Company entity have many Orders and Orders have many OrderLines, wich is a link with products, but every product is linked to company. That makes even less sense.

Take a look.

The aggregate GetOrderLine will bring these attributes, including the CreatedBy (UserId) which is in Order.


I hope it helps you!

Lenon Manhães wrote:

Take a look.

The aggregate GetOrderLine will bring these attributes, including the CreatedBy (UserId) which is in Order.


I hope it helps you!

But then I only can see ther CreatedBy user of the Order. 

My goal is to save also the CreatedBy user of an OrderLine.

So for examle user A creates Order1, and user B puts OrderLine 1 and 2 on it. User C puts OrderLine 3 at order 1.

In you example I will expect only the CreatedBy of Order is stored. 


Solution

I've solved the problem.

I have made an new aggregate which get all of my Products based on the CompanyId of the selected Order.


Thanks for your help!

Solution