Problem with adding fields from EcoResProduct to PriceDiscAdm form

Hi, 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?

I don’t see any tag with the version of AX. Is this about AX 2012?
What you see is the normal, although not intuitive, behaviour. If you have joined data sources, AX will try to save all of them.
If you want to prevent it, override write() and validateWrite() methods of the data source (that you don’t want to save). Remove super() from both and return true from validateWrite().

Yes, sorry, this is AX 2012. Thank you, it helped and now it works ok. There is only a problem that when I choose a product, the new field from EcoResProduct updates only after turning the form off and on again, no after create record in grid. Should I refresh my EcoResProduct datasource somewhere?

I’m sorry, but I don’t know what you did, so I’m unable to comment on to fix it. You’ll have to give us more information.

I did as you wrote and it works fine now, but when I write a record the value in a relational field from EcoResProduct datasource doesn’t change. The value in this field is completed only when I enable the PriceDiscAdm form again. I think this is a problem with datasource refresh.

I guess that “I write a record” means that you save a record through GUI. Refreshing the data source won’t help you, IMHO, because no record was loaded originally. Re-reading nothing will still give you nothing. You’ll need to re-execute the query, or set a record to the data source by yourself.
(I’m guessing a lot, because you didn’t explain your scenario, what I say may be wrong if I guessed your situation incorretly.)
There may be a better solution for your business scenario, but I have no information about it, so I can’t propose anything.