Duplicate address record entry through Data entity in Dynamics 365 Finance and Operations

Introduction:
In this blog, we will see how to allow system for accepting duplicate addresses of customer, vendor or any other, through doing bit change in Data Entity 


Solution:
For allowing duplicate entries we will create one field in LogisticsPostalAddress. Here field name is as IsCreateFromEntity. Field-IsCreateFromEntity will be used as flag, type of boolean / NoYesId (EDT).

[ExtensionOf(tableStr(LogisticsPostalAddressBaseEntity))]
final class LogisticsPostalAddressBaseEntityCFSJSTable_Extension
{
    public static LogisticsLocationId resolveRemittanceAddressLocationId(LogisticsPostalAddressBaseEntity _postalAddressEntity, DirPartyNumber _partyNumber)
    {
        LogisticsLocationId locationId, locationIdCreateNew;

        locationId = next resolveRemittanceAddressLocationId(_postalAddressEntity, _partyNumber);

        if(_postalAddressEntity.IsCreateFromEntity)
        {
            locationId = locationIdCreateNew;
        }

        return locationId;
    }
}

Aforementioned code would replace the standard locationId variable with new locationIdCreateNew which will be null always. Once new variable locationIdCreateNew is replaced with standard code,  system will generate the new locationId in the LogisticsLocation(Table) and create the same duplicate address along with state, city, country, zipcode and all other respective fields.

Moreover, we will just need to pass YES value to the newly created field ISCreateFromEntity while creating the new address and run the execution. How easy it is!!!

Thanks for reading !!!


Share Story :