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
744 stars 245 forks source link

page trigger OnInsertRecord does not work as before #7878

Open AlexCeg opened 1 week ago

AlexCeg commented 1 week ago

Please include the following with each issue:

1. Describe the bug I have an extension that inserts a record in the OnInsertTrigger of a page extension and returns false in this trigger. This does not work in BC25. The return ist ignored

2. To Reproduce

  1. Go to a sales order and try to insert a line. It works in BC24 and it does not work in BC25.
pageextension 50106 "EXT" extends "Sales Order Subform"
{
    trigger OnInsertRecord(BelowxRec: Boolean): Boolean
    begin
        if CheckFeatureActive() then begin
            Rec.Insert();
            exit(false);
        end else
            exit(true);
    end;

    local procedure CheckFeatureActive(): Boolean
    begin
        exit(true); // e.g. check some setup
    end;
}

3. Expected behavior There should be no change.

4. Actual behavior An error occurrs which is quite dangerous when we bring our customers to BC25 because they are not able to create sales orders any more.

5. Versions:

Final Checklist

Please remember to do the following:

dannoe commented 1 week ago

The return value already handles if the insert should happen. Why do you call Rec.insert and return false? If you want to insert the record, just return true and if not, return false inside the trigger.

AlexCeg commented 2 days ago

@dannoe It is just an easy example. If I insert the record return false I get an error because the return value is ignored and the standard tries to insert the record as well.