Using DocRefEntity on table with no DataAreadID

Hello,

I am trying to create a D365FO data entity to add documents to the SalesAgreementHeader table. The primary datasource I am using is the DocuRefEntity with the SalesAgreementHeader as a child datasource. When working with other tables that have dataAreaIds, I would setup relations between the RefTableID, RefRecId and RefCompanyId. With this table, I only have the RefTableId and the RefRecId. The field RefCompanyId is required, but it will not allow me to have it as an exposed field (inert not allower for field DocuRefEntity.RefCompanyId).

pastedimage1527018001640v1.png

I tried to set it in the mapEntityToDataSource and PostLoad methods, and neither of these work. How can I set the RefCompanyId for this entity?

Shawn

I have determined that the issue was more that the primary table that I need to attach the document reference to is not the SalesAgreementHeader table, but the AgreementHeader table in which the SalesAgreementHeader table is derived from. I changed the data source and set the relations, but it still doesn’t work. Now I just get an error that “Error(s) occurred while writing entity record”.

pastedimage1527648870396v1.png

I believe the problem is the required RefCompanyId relationship that I can’t figure out how to setup. Since the field needed for the relationship is in the derived table, AgreementHeader_SalesAgreementHeader, I tried to setup a relation to that field, but it doesn’t work. How can I setup a relationship between the DocuRefEntity.RefCompanyId field and the AgreementHeader_SalesAgreementHeader.CustomerDataAreaId?