0

我为我的自定义字段创建了一个表和一个页面,并扩展了 Customer 表和 Sales Header。

基本上,我想在客户表、卡和列表中创建一个新字段。此字段也需要出现在客户名称下的销售发票中。

这里的想法是,如果我更改销售发票页面中的字段值,客户中的值会自动更改。为了实现这一点,我需要使用事件。这对我来说很难,该字段需要可编辑,因此它不能属于 FlowField 类。但是,如果字段不是 Flowfield(通过 CalcForm),则无法从 Customer 获取值。

我完全不知道如何链接该字段并使其可编辑。(注意:我正在使用 AL 编写代码。)我该如何解决这个问题?

table 50140 "EORI Table"
{
    DataClassification = ToBeClassified;

    fields
    {
        field(1; Customer_No; Code[20])
        {
            DataClassification = ToBeClassified;

        }
        field(2; EORI; Text[50])
        {
            DataClassification = ToBeClassified;
            Editable = true;
        }
    }

    keys
    {
        key(PK; Customer_No)
        {
            Clustered = true;
        }
    }
    
}
page 50121 "EORI Card"
{
    PageType = Card;
    ApplicationArea = All;
    UsageCategory = Administration;
    SourceTable = "EORI Table";

    layout
    {
        area(Content)
        {
            group(GroupName)
            {
                field("Customer No."; Customer_No)
                {
                    ApplicationArea = All;
                }
                field(EORI; EORI)
                {
                    ApplicationArea = All;
                    Editable = true;
                }
            }
        }
    }

    actions
    {
        area(Processing)
        {
            action(ActionName)
            {
                ApplicationArea = All;

                trigger OnAction()
                begin

                end;
            }
        }
    }

    var
        myInt: Integer;
}
page 50122 "EORI List"
{
    PageType = List;
    ApplicationArea = All;
    UsageCategory = Lists;
    SourceTable = "EORI Table";
    CardPageId = "EORI Card";

    layout
    {
        area(Content)
        {
            repeater(GroupName)
            {
                field("Customer No."; Customer_No)
                {
                    ApplicationArea = All;
                }
                field(EORI; EORI)
                {
                    ApplicationArea = All;
                    Editable = true;
                }
            }
        }
    }

    actions
    {
        area(Processing)
        {
            action(ActionName)
            {
                ApplicationArea = All;

                trigger OnAction()
                begin

                end;
            }
        }
    }

    var
        myInt: Integer;
}
tableextension 50123 EORITableExt extends Customer
{
    fields
    {
        field(50123; EORI; Text[50])
        {
            TableRelation = "EORI Table".EORI;
            ValidateTableRelation = true;
            Editable = true;
        }
    }
}
pageextension 50125 EORIPageCardExt extends "Customer Card"
{
    layout
    {
        addafter(Name)
        {
            field("EORI No."; EORI)
            {
                ApplicationArea = All;
                Editable = true;
                Lookup = true;
            }
        }
    }

    actions
    {
        addafter(Prices)
        {
            action(EORI)
            {
                ApplicationArea = All;
                RunObject = page "EORI List";
            }
        }
    }
}

pageextension 50126 EORIPageListExt extends "Customer List"
{
    layout
    {
        addafter("No.")
        {
            field("EORI No."; EORI)
            {
                Editable = true;
            }
        }
    }

    actions
    {
        addafter(ApprovalEntries)
        {
            action(EORI)
            {
                RunObject = page "EORI List";
                RunPageLink = "Customer_No" = field("No.");
            }
        }
    }
}
4

1 回答 1

0

你需要这样的东西

pageextension 50100 SalesOrder extends "Sales Order"
{
    layout
    {
        addafter("Sell-to Customer No.")
        {
            field(EORI; CustEORIG)
            {
                Caption = 'Customer EORI';

                trigger OnValidate()
                var
                    EORITable: Record "EORI Table";
                begin
                    if EORITable.Get(Rec."Sell-to Customer No.") then begin
                        EORITable.EORI := CustEORIG;
                        EORITable.Modify();
                    end;
                end;
            }
        }
    }

    var
        CustEORIG: Text[50];

    trigger OnAfterGetCurrRecord()
    var
        EORITable: Record "EORI Table";
    begin
        if EORITable.Get(Rec."Sell-to Customer No.") then
            CustEORIG := EORITable.EORI;
    end;
}
于 2021-11-12T12:57:32.807 回答