Reference selector with selectable objects

1
Hey guys,   Im currently struggeling to implement my logic into my app. The logic should be as following: I got 2 reference selectors one with a company the other one with products from that company. When i select a company in the first reference selector only the products availiable in that company should show in the second reference selector. My Main enitity is the order with a many to 1 association with the product and the company. The way the second reference selector should know is by the produced by company attribute.  
asked
4 answers
4

Hi Niklas,

 

As a workaround (considering your model)

You may try this, in your page/form:

  • have a reference selector set to Order_Company/Company/Name
    • set the onchage to call nanoflow (with refresh object)
  • have another reference selector set to Order_Product/Product/ProductName
    • set selectable objects property to a datasource microflow, where you will filter results.
  • Done!

 

 

Steps:

Datasource:

 

Nanoflow:

 

 

 

I hope this works for you!

Best regards

 

 

 

 

answered
4

Hi Niklas Höflmayr,

Instead of Adding Company Name in Product Entity you could make use of Mendix association to Avoid extra logic to fetch the data.


You need to Add an Association between company & Product. Add a Reference selector in your Product to select the company.
 


Then in your Second Reference Selector, you constrain your Data using the Constrained by option in Reference Selector.
 

Go to the Selectable objects Section in the Second Reference Selector and set the Source to Xpath and there will be a Constrained by option where you can select the XPath between Company. 

For your Reference:

 

 

Hope it Helps!!

answered
0

Hi there,

 

What I would recommend is switching up your domainmodel to create a more sustainable application for what you want:

  1. Add an entity between Product and Order called OrderLine
    1. When adding a product to the order, you create a productline that links the product to the order.
    2. This Orderline contains information such as how many of a product you need
  2. Add an association between Product and Company (1 company, * products)
  3. Add the reference selector on the product to select which company it is linked to
  4. When creating an order, you can then select the company and show a list of products associated with that company over assocation

This will be the easiest way to create your concept and also reduce possible errors

 

If you have any questions, do ask them!

Good luck

answered
0

hii Niklas Höflmayr

 there is no relation between company and product so make a so make company and product association with one to many [1-*]

best practice is remove product_by_cmompany attribute from product entity , company and product entity association will connect one company to multiple products

and make another helper entity without any attribut and make following associations 

helper to order [1-*]

helper to company [1-1]

helper to product[1-1]

 

configure your domain modal like picture 

and then after rightclick on entity generate overview pages for all by clicking select all 

 now put the data view on the page where you want ot show the two refrence selectors with datasource helper entity

and choose attribute of both refrence selectors in first choose company name  from helper entity association

and in second refrence selector choose product name from helper entity association

 

now go to the selectable object tab in the second refrence selector

and click to the edit containt  by [edit]

and now choose the path where product_association have 

 

 

now just click ok and ok 

make sure dont use your previous pages after domain model changes because association provides you the dropdown based selectation when you will enter the product for a comapany 

i hope it will help you.

Best Regards 

answered