0

我正在为 BC Customer 表扩展字段映射。我在我的 Dataverse 中添加了一个 vatid 字段。我希望数据在 BC Customer VAT Registration No. 和 vatid 之间双向传递。

我创建了一个程序并基于此站点扩展了 crm 帐户表: https ://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/administration/administration-custom-cds-integration

这是 CRM 帐户扩展代码:

tableextension 50403 AccountExt extends "CRM Account"
{
    Description = 'Business that represents a customer or potential customer. The company that is billed in business transactions.';

    fields
    {
        field(50404; new_vatid; Text[100])
        {
            ExternalName = 'new_vatid';
            ExternalType = 'String';
            Description = '';
            Caption = 'VATID';
        }
    }
}

这是自定义字段映射代码:

Codeunit 50402 IFMEFC
{

    [EventSubscriber(ObjectType::Codeunit, Codeunit::"CDS Setup Defaults", 'OnAfterResetCustomerAccountMapping', '', true, true)]
    local procedure HandleOnAfterResetCustomerAccountMapping(IntegrationTableMappingName: Code[20])
    var
        crmAccount_CRMAccount: Record "CRM Account";
        Customer: Record Customer;
        IntegrationFieldMapping: Record "Integration Field Mapping";
    begin

        InsertIntegrationFieldMapping(
        IntegrationTableMappingName,
        Customer.FieldNo("VAT Registration No."),
        crmAccount_CRMAccount.FieldNo("new_vatid"),
        IntegrationFieldMapping.Direction::Bidirectional,
        '', true, false);
    end;

    procedure InsertIntegrationFieldMapping(IntegrationTableMappingName: Code[20]; TableFieldNo: Integer; IntegrationTableFieldNo: Integer; SynchDirection: Option; ConstValue: Text; ValidateField: Boolean; ValidateIntegrationTableField: Boolean)
    var
        IntegrationFieldMapping: Record "Integration Field Mapping";
    begin
        IntegrationFieldMapping.CreateRecord(IntegrationTableMappingName, TableFieldNo, IntegrationTableFieldNo, SynchDirection,
            ConstValue, ValidateField, ValidateIntegrationTableField);
    end;

我已经在我的 Business Central Cloud Microsoft 沙箱中发布了扩展,将 Business Central 连接到 Dataverse,运行了完全同步,完成后,重置它,然后再次运行。

同步不会更改 Dataverse 中自定义字段的值或 Business Central 中的增值税注册号。他们保持不变。我的 AL 代码中是否缺少用于同步自定义字段的内容?

4

0 回答 0