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, ...
Answered

Execute code before data export with data entity

(0) ShareShare
ReportReport
Posted on by 23

Hi All,

I have a requirement whereby I need to build the data in a table and then export it using a data entity. So at the start of the export, some code needs to be executed to build that table and then export it.

I overwrote several methods on the data entity but no luck. In the code below you see it three times. It only needs to be executed once, but three times in this example to show I tried different methods. The odd thing is also that the breakpoints here don't get hit while debugging (the postLoad method does get hit). So it's obvious that something is wrong, but what. 

Any thoughts appreciated.

Cheers,

Gerard Verbruggen

public class MyentityClass extends common
{
    public void postLoad()
    {
        super();
    }

    /// 
    ///
    /// 
    /// 
    /// 
    public void initializeEntityDataSource(DataEntityRuntimeContext _entityCtx, DataEntityDataSourceRuntimeContext _dataSourceCtx)
    {
        Myclass::MyMethod();
        super(_entityCtx, _dataSourceCtx);
    }

    /// 
    ///
    /// 
    /// 
    /// 
    public void mapDataSourceToEntity(DataEntityRuntimeContext _entityCtx, DataEntityDataSourceRuntimeContext _dataSourceCtx)
    {
        Myclass::MyMethod();
        super(_entityCtx, _dataSourceCtx);
    }

    /// 
    ///
    /// 
    /// 
    /// 
    public void mapEntityToDataSource(DataEntityRuntimeContext _entityCtx, DataEntityDataSourceRuntimeContext _dataSourceCtx)
    {
        Myclass::MyMethod();
        super(_entityCtx, _dataSourceCtx);
    }

}
 

I have the same question (0)
  • AnithaEswaran Profile Picture
    2,032 on at

    Hi,

    Instead of populating the data in new table and exporting it, you can make the new table as the data source .

    Regards,

    Anitha.E

  • g.verbruggen Profile Picture
    23 on at

    Thanks Anitha,

    Smart idea which I will surely implement. But it does not explain why the code is not hit and therefor the code is not executed to create the records in the table. Any thoughts on that ?

    Cheers,

    Gerard

  • Martin Dráb Profile Picture
    237,953 Most Valuable Professional on at

    If you have no records to export, none of the methods will be called. They're called when exporting data, which doesn't happen if there is nothing to export.

    Can you tell us more about your business scenario, please?

  • g.verbruggen Profile Picture
    23 on at

    Thanks Martin,

    When adding a dummy record in the table, the postload is triggered and the breakpoint hits on the super(). The other three methods however are not triggered. The one dummy record is exported.

    The requirement is to have the WIP values (production order) in a PowerBI report. I want to use the code from the ProdRawmaterialInProgressDP class to get this data.

    Cheers,

    Gerard

  • Verified answer
    Martin Dráb Profile Picture
    237,953 Most Valuable Professional on at

    I think that mapDataSourceToEntity() should be called and the other two methods are used on import. But none of the fourth can be used to generate data vefore export, AFAIK, therefore it doesn't really matter.

    The ProdRawmaterialInProgressDP takes the data from a query, therefore the right approach would be creating an entity with the same (or similar) query. Look at ProdRawmaterialInProgress query and ranges added in ProdRawmaterialInProgressDP.processReport(). There are also some calculated values, such as ItemName - that's what can be handled by postLoad().

  • g.verbruggen Profile Picture
    23 on at

    Thanks ! Not the answer I was hoping for it is what it is. I will start working on this other approach.

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 592 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 305 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans