I often get asked by developers where to best put code on data entities for various import and export use cases. When this occurs I always share this image that I have been holding on to for years to show case the method sequence data entities go through.
This image provides a few important take aways:
- The postLoad method is the recommended method for setting virtual fields when exporting data.
- The mapEntityDataSource method is a commonly used method to set values of fields on DMF imports.
- The postLoad method is called by the import process. This is important because any custom logic to set fields on export can slow down the import process on that entity.
- Be careful using methods such as postTargetProcess because this is called for each thread if you are importing with mulithreading.
Keep reading about D365 tips and tricks here: https://markedcode.com/index.php/category/d365/