Hi everyone,
I am building a custom OData data entity to expose document attachments for a custom table called MPWorkerTransHeader (from a custom module), similar to how CustomerAttachmentsV2Entity works for CustTable.
My entity setup:
- Root datasource: DocuRefEntity
- Joined datasource: MPWorkerTransHeader (IsReadOnly: Yes)
-MPWorkerTransHeader joined with HcmWorker
- Relations on MPWorkerTransHeader:
- DocuRefEntity.RefRecId == MPWorkerTransHeader.RecId
- DocuRefEntity.RefTableId == MPWorkerTransHeader.TableId
- DocuRefEntity.RefCompanyId == MPWorkerTransHeader.DataAreaId
- No ranges defined
- IsPublic: Yes
- Entity class only has postLoad() to populate FileContents virtual field
The problem:
1. GET returns empty even when I manually insert a DocuRef record via SQL with the correct RefTableId and RefRecId pointing to MPWorkerTransHeader
2. POST returns: "Write returned RecId 0 for table row of type 'MPWorkerTransDocumentAttachmentEntity'"
I noticed that DocuRefEntity has:
- IsPublic: No
- Tags: Internal use only
My questions:
1. Is DocuRefEntity meant to be used as a root datasource for custom entities, or is it truly internal only?
2. Why would GET return empty even when the DocuRef record exists in SQL with the correct RefTableId?
3. For POST, why does Write return RecId 0 when DocuRefEntity is the root datasource?
4. Should I use DocuRef table directly as root instead of DocuRefEntity?
Any guidance is appreciated. Thank you