AL icon indicating copy to clipboard operation
AL copied to clipboard

Odd behavior MyCodeunit.RUN(MyRecord)

Open dkorinets opened this issue 9 years ago • 2 comments

In case of: IF NOT MyCodeunit.RUN(MyParamsRecord) then .... performing my code stops, even does not try to reach MyCodeunit OnRun trigger.

In case of: MyCodeunit.RUN(MyParamsRecord); Everything works fine.

dkorinets avatar Sep 15 '17 13:09 dkorinets

I will take a look at what we are emitting. Thanks for reporting!

atoader avatar Sep 18 '17 07:09 atoader

It all looks fine to me. I've used the following code to reproduce. Please let me know if I am getting something wrong.

codeunit 50109 MyCodeunit
{
    TableNo = Customer;

    trigger OnRun();
    begin
        Message('Running codeunit 50109');
    end;
}

codeunit 50110 FailingCodeunit
{
    TableNo = Customer;

    trigger OnRun();
    var 
        e : XmlElement;
        t : Text;

    begin
        Message('Running codeunit 50110');
        t := e.Name;
        Message('Unreachable');
    end;
}

page 50101 MyPage
{
    PageType = Card;

    actions
    {
        area(processing)
        {
            action(RunCodeunit)
            {
                trigger OnAction();
                var
                    r : Record Customer;
                    c : Codeunit MyCodeunit;
                begin
                    if NOT c.Run(r) then
                        Message('Something went wrong')
                    else
                        Message('Ran');
                end;
            }

            action(RunCodeunitStatic)
            {
                trigger OnAction();
                var
                    r : Record Customer;
                begin
                    if NOT Codeunit.Run(50109, r) then 
                        Message('Something went wrong')
                    else
                        Message('Ran');
                end;
            }

           action(RunFailingCodeunit)
            {
                trigger OnAction();
                var
                    r : Record Customer;
                    c : Codeunit FailingCodeunit;
                begin
                    if NOT c.Run(r) then
                        Message('Something went wrong')
                    else
                        Message('Ran');
                end;
            }

            action(RunFailingCodeunitStatic)
            {
                trigger OnAction();
                var
                    r : Record Customer;
                begin
                    if NOT Codeunit.Run(50110, r) then 
                        Message('Something went wrong')
                    else
                        Message('Ran');
                end;
            }
        }
    }
}

atoader avatar Sep 19 '17 08:09 atoader