The weirdest bug ever

The weirdest bug ever

EDIT: The Grammarly extension is the root cause of the problem! Thanks, Erik Hougaard for pointing this up!

It took me a while to figure out what to do after consuming large amounts of holiday calories, and how to spend them. I hope my brain cells used them well since I decided to play with Business Central instead of going to the gym.

While I was testing some scenarios with Blobs I encountered some weird behavior. This then drove me in a completely different direction than I was expecting. So I started debugging and it took me quite some time to find out what the root of the problem was.

I know I know, I didn’t explain much, but here it goes. If you have a property Multiline = true defined on your page field, the OnValidate trigger won’t be executed. Yeah, you read it correctly, and yeah, my reaction was the same; that is crazy.

I tested it across different versions, and the bug was introduced with the last minor update of Business Central; version 23.5.

Demo

If you are still confused, let’s take a look at the simple example together. Here, I created a demo page including a field with a Multiline property and a simple code inside the OnValidate trigger, which shows a Message of a text we entered.

page 75100 "Demo Page"
{
    PageType = Card;
    ApplicationArea = All;
    UsageCategory = Administration;

    layout
    {
        area(Content)
        {
            field(Test; Test)
            {
                ApplicationArea = All;
                MultiLine = true;

                trigger OnValidate()
                begin
                    Message(Test);
                end;
            }
        }
    }

    var
        Test: Text;
}

However, if you check the demo GIF below, you can notice that we are missing the Message dialog.

On the other hand, if you take a look at the following GIF, note that the dialog with the text is shown. The only difference is the version of BC used. The first example (not working correctly) shows BC 23.5, and the second (working correctly) shows BC 23.4.

Base app examples

Ok, you can say, this is just one simple innocent bug that may not be that common. That can be true; you may not encounter many such scenarios. However, multiple places inside standard Microsoft code will silently stop working.

One of these is the Work description on Sales documents, which won’t be saved after you enter the value.

group("Work Description")
{
    Caption = 'Work Description';
    field(WorkDescription; WorkDescription)
    {
        ApplicationArea = Basic, Suite;
        Importance = Additional;
        MultiLine = true;
        ShowCaption = false;
        ToolTip = 'Specifies the products or service being offered';

        trigger OnValidate()
        begin
            Rec.SetWorkDescription(WorkDescription);
        end;
    }
}

So what could happen is this: the user will create a Sales Order or Invoice, or whatever; he will populate the Work Description for that document; he will Post it, and then he will either be surprised or he won’t even notice that Work Description is missing. And this is only one of the examples and scenarios.

And now is the time to take a new piece of cake, or two! Hope you are enjoying as I am!