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

What is the purpose of MapDatasourceToEntity method in DataEntity

(0) ShareShare
ReportReport
Posted on by 2,426

Good Morning,

I am trying to understand what does MapDatasourceToEntity method actually does ?

Please provide some example to understand.

Regards,

Have a great day.

I have the same question (0)
  • Verified answer
    Satish Panwar Profile Picture
    14,671 Moderator on at

    The same question has been answered in previous thread. Take a look

    community.dynamics.com/.../data-entity-methods

  • AX 2012 r3 Profile Picture
    2,426 on at

    Hi Satish ,

    Thanks for the reply.

    I have seen this post

    but here it is mentioned like this.

    MapdatasourcetoEntity- if you want to write any custom logic while exporting data out of the system you can override this method

    I donot understand "out of system".

    Can you please give me an example.

    Regards.

    Have a great day.

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

    Out of the system means  for exporting .  Use metadata search to find standard example.

  • WillWU Profile Picture
    22,361 on at

    Hi AX2012 r3,

    There is another method called "mapEntityToDataSource".

    Please have a look at the following DOC:

    https://docs.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/data-entities/data-entity-computed-columns-virtual-fields#example-use-a-virtual-field-to-receive-and-parse-an-inbound-field

    This method contains the logic of the inbound field.

    And "MapDatasourceToEntity" is the opposite method to write codes about outbound fields.

    The so-called outbound and inbound means the import and export of entity data.

    Hope this helps.

  • AX 2012 r3 Profile Picture
    2,426 on at

    Here for testing i created one entity and i have one field extraamount (real).

    I have this field in table and Data entity and Staging.

    I tried filling this as 50 in "MapDatasourceToEntity" But it is not getting filled when exported.

    Am i missing any thing.

    Please guide.

    Regards,

    Have a great day.

  • WillWU Profile Picture
    22,361 on at

    Hi partner,

    Please provide your code if possible.

  • AX 2012 r3 Profile Picture
    2,426 on at

     public void mapDataSourceToEntity(DataEntityRuntimeContext _entityCtx, DataEntityDataSourceRuntimeContext _dataSourceCtx)
        {
            if(_dataSourceCtx.name() == dataEntityDataSourceStr(DEntityTableEntity, DEntityTable))
            {
                this.ExtraAmount = 50;
                this.Description = "123";
            }
    
            super(_entityCtx, _dataSourceCtx);
    
            
        }

    Second Way i tried

    public void mapDataSourceToEntity(DataEntityRuntimeContext _entityCtx, DataEntityDataSourceRuntimeContext _dataSourceCtx)
    {
    if(_dataSourceCtx.name() == dataEntityDataSourceStr(DEntityTableEntity, DEntityTable))
    {
    DEntityTable de = _dataSourceCtx.getBuffer();
    
    de.ExtraAmount = 50;
    de.Description = "123";
    }
    
    super(_entityCtx, _dataSourceCtx);
    
    }

    Please tell me what wrong did i do 

  • Verified answer
    WillWU Profile Picture
    22,361 on at

    Hi partner,

    It seems you are assigning values to the table DEntityTable, but this method is to pass the values in the table to the entity.

    de.ExtraAmount = 50;
    de.Description = "123";

    If your entity contains these two fields.You can try to change them into:

    this.ExtraAmount =50;

    this.Description ="123";

    Hope this helps.

  • AX 2012 r3 Profile Picture
    2,426 on at

    Hi,

    I donot understand which one to be considered i tried both but not able to export.

    Can you provide any example code

    Regards.

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

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans