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

Announcements

News and Announcements icon
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,494

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,741 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,494 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,741 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,353 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
    259 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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders

These are the community rock stars!

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

#1
Subra Profile Picture

Subra 386

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 382 Super User 2026 Season 1

#3
Martin Dráb Profile Picture

Martin Dráb 270 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans