microsoft / AL

Home of the Dynamics 365 Business Central AL Language extension for Visual Studio Code. Used to track issues regarding the latest version of the AL compiler and developer tools available in the Visual Studio Code Marketplace or as part of the AL Developer Preview builds for Dynamics 365 Business Central.
MIT License
722 stars 242 forks source link

Record and Page "Error Message" lose ability to navigate to field #7640

Closed navdotnetreqs closed 5 months ago

navdotnetreqs commented 6 months ago

If I collect an errorinfo into temporary record "Error Message" and then show the "Error Message" -page, I cannot navigate directly to the related field - I can only use the action "Open related record" to open the related record. If I throw the error directly, the navigation works.

Eg.

    [ErrorBehavior(ErrorBehavior::Collect)]
    local procedure Test1()
    var
        Customer: record customer;
        FieldEmptyErrorInfo: ErrorInfo;
    begin
        Customer.FindLast();
        FieldEmptyErrorInfo.Message :=
            StrSubstNo('Address must have a value in Customer %1.', Customer."No.");

        FieldEmptyErrorInfo.RecordId := Customer.RecordId;
        FieldEmptyErrorInfo.AddNavigationAction(
            StrSubstNo('Show Customer %1 field Address', Customer."No.")
        );
        FieldEmptyErrorInfo.FieldNo(Customer.FieldNo(Address));
        FieldEmptyErrorInfo.PageNo(Page::"Customer Card");
        //      FieldEmptyErrorInfo.Collectible := true;
        Error(FieldEmptyErrorInfo);

    end;

Works as expected image

image

But if I set Collectible as true, and then run

procedure ShowErrors()
    var
        TempErrorMsg: Record "Error Message" temporary;
        DataTypeMgt: Codeunit "Data Type Management";
        ErrorInfo: ErrorInfo;
    begin

        foreach ErrorInfo in System.GetCollectedErrors() do begin
            TempErrorMsg.LogDetailedMessage(ErrorInfo.RecordId, ErrorInfo.FieldNo, TempErrorMsg."Message Type"::Error, ErrorInfo.Message, ErrorInfo.DetailedMessage, '');
            TempErrorMsg.SetErrorCallStack(ErrorInfo.Callstack);
            TempErrorMsg.Modify();
        end;

        Page.Run(Page::"Error Messages", TempErrorMsg);
    end;

I can no longer navigate to the field, even though the field name is listed in the details factbox. image

navdotnetreqs commented 6 months ago

Not only does the Open related record -function not open to the correct field, viewin the error (as in clicking the red text), shows the error but none of the error's actions.

image

kalberes commented 5 months ago

Does not look like an issue with the preview AL compiler and latest BC server. It looks like more an issue with the used system application objects, or a runtime issue. image