Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Unanswered

isAnyFieldSet method for Data Source added to Data Entity

(0) ShareShare
ReportReport
Posted on by 122

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.

  • JackieMc Profile Picture
    JackieMc 122 on at
    RE: isAnyFieldSet method for Data Source added to Data Entity

    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.

  • Martin Dráb Profile Picture
    Martin Dráb 230,848 Most Valuable Professional on at
    RE: isAnyFieldSet method for Data Source added to Data Entity

    I moved your question here from the General forum because I'm pretty sure that it's about F&O.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,979 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,848 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans