Skip to content

[NL][Report][11415][ImportPostCodesUpdate][OnPreReport] Add integration events OnBeforeProcessImportLines, OnAfterReadNewPostCodeRange and OnAfterCloseImportFile #30167

@KateDovgalova

Description

@KateDovgalova

Why do you need this change?

In 4PS Construct we need to show progress window when importing file in report 11415 "Import Post Codes Update". To implement this, we need three new events: OnBeforeProcessImportLines to initialize/reset the dialog before the loop starts, OnAfterReadNewPostCodeRange to update it on each processed record, and OnAfterCloseImportFile to close it once the file is fully processed.

Describe the request

Dear ALAppExtensions team,

On behalf of 4PS I would like to request integration events 'OnBeforeProcessImportLines', 'OnAfterReadNewPostCodeRange' and 'OnAfterCloseImportFile' to be added to trigger OnPreReport of report 11415 "Import Post Codes Update":

    trigger OnPreReport()
    var
        FileMgt: Codeunit "File Management";
        ImportFile: File;
        Header: Text;
        Line: Text;
        ChangeType: Option Delete,Modify,Insert;
        Continue: Boolean;
    begin
        ImportFileName := FileMgt.UploadFile('', '*.txt');

        ImportFile.TextMode := true;
        ImportFile.WriteMode := false;
        ImportFile.Open(ImportFileName);

        ImportFile.Read(Header);
        ProcessHeader(Header);

        Continue := true;
        OnBeforeProcessImportLines(); //new

        while (ImportFile.Pos < ImportFile.Len) and Continue do begin
            ImportFile.Read(Line);

            if IsFooter(Line) then
                Continue := false
            else begin
                ChangeType := ReadInteger(Line, 1, 1);

                OldPostCodeRange.Init();
                OldPostCodeRange."Post Code" := FormatPostCode(CopyStr(ReadText(Line, 18, 6), 1, 20));
                OldPostCodeRange.Type := ReadInteger(Line, 24, 1) + 1;
                OldPostCodeRange."From No." := ReadInteger(Line, 25, 5);
                OldPostCodeRange."To No." := ReadInteger(Line, 30, 5);
                OldPostCodeRange.City := CopyStr(ReadText(Line, 53, 24), 1, 30);
                OldPostCodeRange."Street Name" := CopyStr(ReadText(Line, 118, 43), 1, 50);

                NewPostCodeRange.Init();
                NewPostCodeRange."Post Code" := FormatPostCode(CopyStr(ReadText(Line, 202, 6), 1, 20));
                NewPostCodeRange.Type := ReadInteger(Line, 208, 1) + 1;
                NewPostCodeRange."From No." := ReadInteger(Line, 209, 5);
                NewPostCodeRange."To No." := ReadInteger(Line, 214, 5);
                NewPostCodeRange.City := CopyStr(ReadText(Line, 237, 24), 1, 30);
                NewPostCodeRange."Street Name" := CopyStr(ReadText(Line, 302, 43), 1, 50);

                OnAfterReadNewPostCodeRange(NewPostCodeRange); //new

                case ChangeType of
                    ChangeType::Insert:
                        InsertRange();
                    ChangeType::Modify:
                        ModifyRange();
                    ChangeType::Delete:
                        DeleteRange();
                end;
            end;
        end;

        ImportFile.Close();
        OnAfterCloseImportFile(); //new
    end;
    [IntegrationEvent(false, false)]
    local procedure OnBeforeProcessImportLines()
    begin
        //new
    end;

    [IntegrationEvent(false, false)]
    local procedure OnAfterReadNewPostCodeRange(NewPostCodeRange: Record "Post Code Range")
    begin
        //new
    end;

    [IntegrationEvent(false, false)]
    local procedure OnAfterCloseImportFile()
    begin
        //new
    end;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions