To reviewD365FO

Customer import through the data entity does not default values from the customer group

A 2017 extension on CustCustomerEntity that calls initFromCustGroup during import, so fields like payment terms default from the customer group.

Written for platform update 11; check whether the current customer entity already defaults from the customer group.

First written
Re-read
Versions
D365FO

When you import customers through the customer data entity, fields that the customer form takes from the customer group, such as payment terms, stay empty. This note fixes it with an event handler on the entity.

The original note

Importing customers with the data entity does not initialize data from the customer group: for example, payment terms are not taken from the group automatically.

This extension on the CustCustomerEntity data entity fixes the problem:

[ExtensionOf(dataentityviewstr(CustCustomerEntity))]
final class CustCustomerEntity_Extension
{
    [DataEventHandler(tableStr(CustCustomerEntity), DataEventType::MappedEntityToDataSource)]
    public static void CustCustomerEntity_onMappedEntityToDataSource(Common _sender, DataEventArgs _eventArgs)
    {
        CustCustomerEntity custCustomerEntity = _sender;
        DataEntityContextEventArgs dataEntityContextEventArgs = _eventArgs;

        DataEntityDataSourceRuntimeContext _dataSourceCtx = dataEntityContextEventArgs.parmEntityDataSourceContext();
        if (_dataSourceCtx.name() == dataEntityDataSourceStr(CustCustomerEntity, CustTable))
        {
            CustTable custTable = _dataSourceCtx.getBuffer();
            custTable.initFromCustGroup(CustGroup::find(custTable.CustGroup));
        }
    }
}

Applies to D365FO platform update 11 (Spring 2017).

References