Showing posts with label postTargetProcess. Show all posts
Showing posts with label postTargetProcess. Show all posts

Thursday 24 December 2020

D365 F&O Import Data entity: postTargetProcess, copyCustomStagingToTarget

 D365 F&O Import Data entity: postTargetProcess, copyCustomStagingToTarget methods not called 

No row processing is achieved by enabling "Set-based processing = True"  and is used to imports records really fast.

Data management workspace > Data entities button

set-based

But when you really want to write some "postprocessing" logic, with the above setting the methods "postTargetProcess()", "copyCustomStagingToTarget()" are not called. Data entity with "Set-based processing" = false, calls "postTargetProcess( )"  and "copyCustomStagingToTarget()" method . 

One way  to run  postTargetProcess() code after importing all records with "Set-based processing" = true on  data entity is using post handlers.

[PostHandlerFor(classStr(DmfEntityWriter), methodStr(DmfEntityWriter, write))]

   public static void DmfEntityWriter_Post_write(XppPrePostArgs args)

   {

       DMFDefinitionGroupExecution  _dmfDefinitionGroupExecution = args.getArg('_definitionGroupExecution');

       // come code to iterate target table records exists joined from staging

   }

This method is called for all staging records where TransferStatus::Completed.

As this post hadler method is from the DMF base class DmfEntityWriter, it will be called for all entites.Hence we need to be careful while using this method and handle the logic for different entities with switch case as below.

str callerEntity = dmfDefinitionGroupExecution.EntityXMLName;

              switch (callerEntity)
              {

case 'CustCustomersV3Entity':

// something

break;

}

Thanks & Regards
Sindhu