Using configuration document as default value, allowing user to edit

I have a form where the user can select multiple products. I have created config docs for each product with product name and cost and a one to many association. Users should be able to select multiple products and be able to override the cost for each. The edited value should only be saved on the new form, not the product config doc. I'd also like to display the overridden cost next to each applicable product on the form. Does anyone have any suggestions on how to accomplish this?
2 answers


The way I've done this is to create an intermediate entity in my domain model. To use an example, suppose I have an Order with a many to many association with Products. Assume that Products entity has a Cost attribute. If I want to enable Product cost to be overridden on each Order, I can't do that with the out of the box many to many association. Instead, I need to create an OrderLine entity. The OrderLine entity has a M:1 association with Order entity and a M:1 association with Product entity (i.e. each Order can have many OrderLines and each Product can be used on many OrderLines, but an OrderLine can have 1 Order and 1 Product).

With this structure, I can add an attribute to the OrderLine entity which is OverridePrice. When a user selects a product for an OrderLine, I can copy the price from the Product entity into the OrderLine entity, and also offer the user the ability to override that price on the OrderLine entity without impacting my Product catalog.

I am sure there are other ways to accomplish this, but this is a development pattern I use often.

Hope that helps,



Ok - I made a small example project. Nothing fancy here - this is not a user interface I would deploy to users, but I think it will get you started. I included a small snapshot of data in the package, so when you start it up, you should see a tab page with Orders and Products. If you open (or create) an order, you will see a nested datagrid where you can add OrderLines. When you edit an OrderLine, you can select a Product. When you select a product, the price of the Product from the Product list is placed into the OrderLine. After the product is selected, you are free to edit the OrderLine item price without impacting the Product item price.

6.8.1 Application Package can be downloaded Here