Purpose:
Understand when and how to use postLoad method in data management.
Application:
Dynamics 365 for Finance and Operations
Prerequisites:
- Basic understanding of data entities and how data management works
Business requirement:
Consider, for example, we need to add new field to standard data entity EcoResReleasedProductV2Entity to export a custom field called Manufacturer.
If we come across this business requirement to add a new field to a standard data entity to export additional information then we can achieve this requirement by using the postLoad() method.
PostLoad:
PostLoad() method can be used to provide values in export scenarios for unmapped fields which are created as non-computed fields (Is Computed Field property is set to No) on a data entity.
In the code below, we can see how we can use postLoad() method to populate a custom field added to a standard data entity to export additional information from released products.
Please note, you will need to add a virtual unmapped field to the data entity first before you could use this code.
Code
[ExtensionOf(tableStr(EcoResReleasedProductV2Entity))]
internal final class MAK_EcoResReleasedProductV2Entity_Entity_Extension
{
public void postLoad()
{
InventTable inventTable;
MAK_ManufacturerTable manufacturerTable;
next postLoad();
inventTable = InventTable::find(this.ItemNumber);
manufacturerTable = MAK_ManufacturerTable::findRecId(inventTable.MAK_Manufacturer);
this.ManufacturerId = manufacturerTable.ManufacturerId;
}
}