web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

GL data entity extension import

(0) ShareShare
ReportReport
Posted on by 6,478

Hello,

I have extended GL data entity with one field.

Export works fine.

During import I want to update LedgerJournalTRans table's field based on some logic,

In which method should I write the code?

I copied events related to mapEntityToDataSource method and insertEnttyDataSource, but during import I can't see those executed.

Breakpoint is not hit, nothing happens.

I have the same question (0)
  • Suggested answer
    Sukrut Parab Profile Picture
    71,710 Moderator on at

    You can write in any of the above methods. mapEntityToDataSource  is called for each datasource on the entity, so you can try to write in it . If you are break point it not hitting  thats a different problem but these methods must be getting called during import.  Which entity you are using ?

  • Johnny Profile Picture
    6,478 on at

    Hi Sukrut,

    I added just an infolog to see and nothing was displayed.

    I'm using Standard LedgerJournalEntity

  • Suggested answer
    Sukrut Parab Profile Picture
    71,710 Moderator on at

    LedgerJournalEntity does set based operation , check if the set based operation is enabled on the entity .  copyCustomStagingToTarget method gets called when you import through this entity , you can take a look at this method and see how  records are inserted and updated and use COC to handle your scenario.

  • MATTGUO Profile Picture
    22,349 Moderator on at

    Hi Johnny,

    You need to use COC to extend the mapEntityToDataSource method,

    I create a test field, and  update LedgerJournalTRans table’s RCashDocRepresPersonId field with the test field.

    Please refer to the following code:

    0488.png

    [ExtensionOf(tableStr(LedgerJournalEntity))]
    final class LedgerJournalEntity_Extension
    {
        public void mapEntityToDataSource(DataEntityRuntimeContext entityCtx, DataEntityDataSourceRuntimeContext dataSourceCtx)
        {
            next mapEntityToDataSource(entityCtx, dataSourceCtx);
            if (dataSourceCtx.name() == "LedgerJournalTRans")
            {
                LedgerJournalTRans ds = dataSourceCtx.getBuffer();
    
                ds.RCashDocRepresPersonId=this.test;
            }
           
        }
    
    }
    

  • fspafj Profile Picture
    257 on at

    Hi MATTGUO,

    I am also trying to update value for a mandatory field xxx in the target data source by using a test field in the mapEntityToDataSource method similarly with your example code above.

    However after importing the source file successfully into staging table, error occured while writing into target with below message:

    Results.Field 'xxx' must be filled in.

    Results.Validations failed while writing entity record.

    I have built the project, model and synced database but the error still occured. What could be the reason for this error?

    Thanks in advance.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 559 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 464 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans