Reputation: 1
I’m new here and I have a question. I would like to add a field to grid from the EcoResProduct table in the PriceDiscAdm form. I added a new datasource InventTable and linked it to the reference datasource EcoResProduct. It looks fine, but when I try to create a new record in the PriceDiscAdmTrans table, it also tries to create a record in the EcoResProduct table. I use original relationships on tables. How to fix it?
Upvotes: 0
Views: 970
Reputation: 381
I think you probably want an outer join with the InventTable unless it's impossible for a PriceDiscAdm record to not have an InventTable record.
Either way though, try adding the EcoResProduct table as a regular data source (not reference) with a join parent of InventTable. I'm prerty sure you want to make that one an outer join. I'm reasonably confident that that not all items are products.
I do think that should solve the issue though. My guess is the reference data sources can't be set not to create if empty or something.
Only do that though if you can guarantee though that there is a 1-1 relationship between InventTable and EcoResProduct though, otherwise you risk duplicating records. I don't have my AOT in front of me so IDK if it's 1-1. If there's not, you'll have to create a grouped query and use aggregates like Max or Min and then build a view on that and use that view in the form instead of the data sources. Perhaps even having to use a sub-view to select the max product recid for each itemid and then a main view that joins that back to the fields in the product table you want.
Even if you don't have to too, using a view will 100% ensure that the form can't write or create data since views are readonly, do you may end up just writing a view anyway if you're new to this and just want to make 100% sure nothing can write or create to the new tables you're adding. Though this crutch could prevent you from growing as a developer if used too often.
Alternatively, you could simply define a display method on the data source, but you will not be able to filter or sort.
Upvotes: 0