We have a requirement to integrate with D365 to create General Journals where some lines will have account strings (Account Type is Ledger) and some lines will have Projects (Account Type is Project). Our preference is to integrate through Rest API hitting the Data Entity (so not using a file upload).
I copied the LedgerJournalEntity (and relevant classes) and updated IsPublic property. I can successfully hit the endpoint and create a GJ using Postman for both scenarios. But for the Project scenario the data on the Project tab isn't being populated (ProjectId, Project Category, etc). I saw this tab is based on LedgerJournalTrans_Project table and added this as a Data Source to my Data Entity.
Things now work properly if I have a line with a Project but I'm getting an error if I have a line with an Account String as it complains about missing required data when trying to insert into LedgerJournalTrans_Project. Through debugging, I'm able to see this is because the isAnyFieldSet method for LedgerJournalTrans_Project datasource in SysDataEntityPersister is returning true.
That method is defined at runtime as follows:
private boolean isAnyFieldSet_DS12(LedgerJournalTrans_Project _ledgerJournalTrans_Project, DataEntityDataSourceRuntimeContext _dataSourceCtx, DataEntityRuntimeContext _entityCtx) { boolean rtrn = false; if(_ledgerJournalTrans_Project.isFieldSet(fieldnum(LedgerJournalTrans_Project,CategoryId))) { return true; } if(_ledgerJournalTrans_Project.isFieldSet(fieldnum(LedgerJournalTrans_Project,ProjId))) { return true; } if(_ledgerJournalTrans_Project.isFieldSet(fieldnum(LedgerJournalTrans_Project,ProjTransDate))) { return true; } if(_ledgerJournalTrans_Project.isFieldSet(fieldnum(LedgerJournalTrans_Project,RefRecId))) { return true; } rtrn = this.isAnyFieldSet_Extensions(_entityCtx, _dataSourceCtx, _ledgerJournalTrans_Project) ? true : false; return rtrn; }
It returns true because RefRecId is populated.
I based my addition of LedgerJournalTrans_Project to this Data Entity on the the way the table LedgerJournalTransExtensionTH was added.
My question is how are the fields to be assessed in the isAnyFieldSet logic determined? I feel my scenario would work if RefRecId wasn't one of the fields being evaluated and the equivalent join field in LedgerJournalTransExtensionTH (LedgerJournalTrans) is included in the isAnyFieldSet logic for that table.
Note: Similar to LedgerJournalTransExtensionTH, I have code in copyCustomStagingToTarget method to only populate LedgerJournalTrans_Project if the AccountType = Project.
Thank you, Martin. This is indeed a F&O question.
I figured it out myself this morning. If anybody faces the same issue, I had added LedgerJournalTrans_Project.RefRecId to the DataEntity itself and this wasn't necessary.
I moved your question here from the General forum because I'm pretty sure that it's about F&O.
André Arnaud de Cal...
291,979
Super User 2025 Season 1
Martin Dráb
230,848
Most Valuable Professional
nmaenpaa
101,156