Blob 字段未显示在 Business Central 页面上

Blob field not displaying on Business Central page

我在 BC 扩展中创建了一个 table 和一个页面。 table 中的字段之一是类型:BLOB。它没有显示在页面上。我试图复制销售 Header table / 销售发票页面中 'Work Description' BLOB 字段发生的情况。我哪里错了?请参阅下面的代码。在此先感谢您的帮助。

table 50050 LogSheets
{
    fields
    {
        // Various fields...
        field(9; DescriptionOfTasksPerformed; BLOB)
        {
        Caption = 'DescriptionOfTasksPerformed';
        }
    }
    var
    ReadingDataSkippedMsg: Label 'Loading field %1 will be skipped because there was an error when reading the data.\To fix the current data, contact your administrator.\Alternatively, you can overwrite the current data by entering data in the field.', Comment = '%1=field caption';
    
    // Cribbed from Sales Header (table & page) - WorkDescription
    procedure GetTasksDescription() TasksDescription: Text
    var
        TypeHelper: Codeunit "Type Helper";
        InStream: InStream;
    begin
        CalcFields(DescriptionOfTasksPerformed);
        DescriptionOfTasksPerformed.CreateInStream(InStream, TEXTENCODING::UTF8);
        if not TypeHelper.TryReadAsTextWithSeparator(InStream, TypeHelper.LFSeparator(), TasksDescription) then
        Message(ReadingDataSkippedMsg, FieldCaption(DescriptionOfTasksPerformed));
    end;
    
    procedure SetTasksDescription(NewTasksDescription: Text)
    var
        OutStream: OutStream;
    begin
        Clear(DescriptionOfTasksPerformed);
        DescriptionOfTasksPerformed.CreateOutStream(OutStream, TEXTENCODING::UTF8);
        OutStream.WriteText(NewTasksDescription);
        Modify;
    end;
}

page 50051 LogSheetCard
{
    Caption = 'Log Sheet';
    PageType = Document;
    RefreshOnActivate = true;
    SourceTable = LogSheets;
    layout
    {
        area(Content)
        {
            group("LogSheetDetails")
            {
                // Various fields...
            }
            group("Tasks")
            {
                Caption = 'Description of tasks performed';
                field("DescriptionOfTasksPerformed"; Rec.DescriptionOfTasksPerformed)
                {
                    ApplicationArea = Basic, Suite;
                    Importance = Additional;
                    MultiLine = true;
                    ShowCaption = false;
                    ToolTip = 'Description of tasks performed';
                    Editable = true;
                    trigger OnValidate()
                    begin
                        Rec.SetTasksDescription(TasksDescription);
                   end;
                }
            }
        }
    }
    var TasksDescription: Text;
    trigger OnAfterGetRecord()
    begin
        TasksDescription := Rec.GetTasksDescription;
    end;
}

在上面代码的底部,有一行:trigger OnAfterGetRecord。这依次调用 GetTasksDescription,后者又调用 CalcFields(DescriptionOfTasksPerformed); 我相信这就是在销售 Header table / 销售发票页面中完成的方式,但 'Description of tasks performed' 下的页面上仍然没有显示框(见下文)? 我已经通过将消息行放在相关过程中来确认正在调用这些代码行。这是一个难题。 screenshot

在您的页面中,您将 table 中的 blob 字段 DescriptionOfTasksPerformed 设置为页面字段的来源:

field("DescriptionOfTasksPerformed"; Rec.DescriptionOfTasksPerformed)

但是您应该使用页面中的全局变量 TasksDescription 作为源:

field("DescriptionOfTasksPerformed"; TasksDescription)