Display more than 1 result.

1
Hi all, See the image for (the relevant part of) my domain model. On the Order_Overview page, I want to display all the products belonging to an order. I added a string-attribute in the Order entity (OrderProducten) and I used the following microflow to retreive the products (see image) The problem is that this microflows gives me just 1 product result while most orders consist of multiple products. Could someone please help me fix this? Kind regards, Tim
asked
5 answers
2

You should add a * - * relation between Order and Product. When saving the Order, retrieve all Products, with a constraint like [OrderRegel_Product/OrderRegel/OrderRegel_Order = $Order]. Then, set the value of the * - * relation to the set you have just retrieved. In the grid, you can now display all product names over this association, which Mendix will display as a comma separated list.

To fix your current problem (which is duplicating data), you should construct a string variable ($ConcatenatedProductNames) outside the loop. Then, in the loop, you add the product name to the string ($ConcatenatedProductNames + ' ' + $IteratorProduct/Name). After the loop, you set the value of your string attribute to the value of the string.

answered
1

What happens in the 'OrderProducten' attribute in the change order action? Do you set the 'Orderproducten' attribute to the productnumber of the product in the iteration? Anyway; if I understand your goal correctly, you should change the orderproducten attribute in this loop to it's current value + the productnumber of the product in the iteration. In this way you will create a list.

Again, if I understand your goal correctly I don't think you will need to create the string variable before the loops and change it afterwards.

answered
0

Is see the images are broken.

Here the domain model: http://nl.tinypic.com/r/ibzam8/9 Microflow: http://nl.tinypic.com/r/1605rb9/9

answered
0

You are now duplicating information in your domain model. A neater way to fix this would be to construct a page as follows:

  • Data view Order
  • Data grid of OrderLines
  • A single column, in which for the order line, you display its product (over the association)
answered
0

Thanks for the help guys! Much appreciated!

answered