PostLoad() in dataentity

My requirement was to automatically calculate the CountryCodePrefix field based on the Country field in a custom table called HAR_ManufacturedInStaging1 in D365 Finance and Operations (D365FO) when importing data from an Excel file.
Code Snippet:-

public class HAR_ManufacturedInStaging1 extends common
{
///


///
///

public void postLoad()
{
super();

        if (this.Country)
        {
            // Extract the first 3 letters of the country name
            this.CountryCodePrefix = subStr(this.Country, 1, 3);
        }
        else
        {
            this.CountryCodePrefix = " ";
        }

    }

}

This isn’t the way how to do it. Override mapEntityToDataSource() method of your entity and implement the logic there. Alternatively you could use postGetStagingData(), if you don’t need to support this logic for OData.

But it’s questionable what the prefix is useful for, because it’s not unique. Don’t you rather want to use ISO code (ISO 3166)?

Sure! Thank you, yet I’m still getting the data and my necessary solution by using postload(). Definitely, i’ll try this !