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

How to update a certain table after the entity has finished executing?

(0) ShareShare
ReportReport
Posted on by 1,965

Hi,

I have a table (TableDemo) that is also used in my entity. After the execution of the entity, i want to update a certain field of this table (tableDemo) for all used records in this entity
This table is inner joined with the main dataSource of the entity.

I have the same question (0)
  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    You can write code in postLoad (import) or mapEntityToDataSource (export) methods of the entity to achieve that.

    You can check the MS doc regarding virtual fields - the use case is a bit different (populate field on import / export) but you can also use similar logic in your case to update a field on export / import.

    docs.microsoft.com/.../data-entity-computed-columns-virtual-fields

  • Suggested answer
    Sergei Minozhenko Profile Picture
    23,093 on at

    Hi IntegrationBeginner,

    Are you talking about the export or import scenario?

    For export scenarios, you can use postLoad or DMFDefinitionGroupExecution.update method.

    Check the thread for more examples: community.dynamics.com/.../is-there-a-work-around-to-enable-incremental-push-for-composite-entities

    For import scenarios you can use postTargetProcess method

    ievgensaxblog.wordpress.com/.../

  • .. Profile Picture
    1,965 on at

    Hi Sergie and Nikolaos,

    Thanks alot both of you. My question was about export.

    I've read your responses in addition to your responses in this link: https://community.dynamics.com/365/financeandoperations/f/dynamics-365-for-finance-and-operations-forum/410246/is-there-a-work-around-to-enable-incremental-push-for-composite-entities

    Based on what i read from this link, postLoad will update the field even if the export failed. So i prefer to use the other suggestion which is DMFDefinitionGroupExecution.update method but i got confused alittle on how to use it.

    So in postLoad, i would have said select forupdate table where  table.uniquefield == this.uniqueField  then update.

    A) However in this method below, you are looping through the staging table, so am i going to put inside this staging table loop the same thing as postLoad? as shown below?

    	ttsbegin;
    	while select MyRootStaging
    					where MyRootStaging.DefinitionGroup   ==  dmfDefinitionGroupExecution.DefinitionGroup
    					   && MyRootStaging.ExecutionId       ==  dmfDefinitionGroupExecution.ExecutionId
    				{
    					select forupdate tableDemo where tableDemo.UniqueField == MyRootStaging.FieldWithValueAsUniqueFieldOftableDemo;
    					tableDemo.Field1 = new value;
    					tableDemo.update();
    					
    				}
    	ttscommit;

    B) also it was suggested to use postLoad or mapEntityToDataSource, may i know the difference between these two methods and when would i need to use each one?

  • WillWU Profile Picture
    22,361 on at

    Hi IntegrationBeginner,

    The Mapentitytodatasource method is used to map inbound field to underlying target datasource. See:

    docs.microsoft.com/.../data-entity-computed-columns-virtual-fields

    Please try the updateEntityDataSource method:

     public boolean updateEntityDataSource(DataEntityRuntimeContext _entityCtx, DataEntityDataSourceRuntimeContext _dataSourceCtx)
     {
      Yourtable table =_dataSourceCtx.getBuffer();
      table.yourfield="....."
      
      return super(_entityCtx, _dataSourceCtx);
     }

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 611 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