web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Debugger issue in Business Central, AL code

(0) ShareShare
ReportReport
Posted on by 80

Hi,

I also posted this on Microsoft/AL (GitHiub). Any feedback here is appreciated.

**Describe the bug**

The app is published and works as expected (Payment Method Code for 8 Sales Orders for Adatum Corporation – and any other I try -  are changed when the Customer Card Payment Method Code is changed), with below launch.json, app.json, and codeunit used to test the debugger.

The debugger does not stop at breakpoints, or otherwise seem to work.

The only result I have seen in the debugger is that the CALL STACK will sometimes show “RUNNING.”

**To Reproduce**

Steps and to reproduce the behavior:

Aside from the below files, have also tried to use in settings.json:

`"al.editorServicesLogLevel": "Debug". (restarted VS Code to take effect)`

And then

`"al.editorServicesLogLevel": "Verbose" (restarted VS Code to take effect)`

 

EditorServices.log, and the debugger (DebuggerServices.log) are NOT output to the

C:\Users\<USER>\.vscode\extensions\... \bin directory.

The only new directory created in the path is 365businessdevelopment.bdev-al-xml-doc-1.0.2, which is empty.

There is this “Unknown Config Setting” added setting to settings.json:

`bdev-al-xml-doc.checkProcedureDocumentation": true, (tried true and false without causing an effect).`

 

Cleared browser cache.

Cleared .alchache in VS Code.

 

In total, no effect to get the debugger to pause on breakpoints.

 

``` AL Code to reproduce the issue ```

launch.json

```

{

    "version": "0.2.0",

    "configurations": [

        {

            "name": "Microsoft cloud sandbox",

            "request": "launch",

            "type": "al",

            "environmentType": "Sandbox",

            "environmentName": "XYZ -SANDBOX",

            "startupObjectId": 22,

            "startupObjectType": "Page",

            "breakOnError": true,

            "launchBrowser": true,

            "enableLongRunningSqlStatements": true,

            "enableSqlInformationDebugger": true

        }

    ]

}

```

in launch.json had also tried:

`"breakOnRecordWrite": true (no effect)`

 

app.json

```

{

  "id": "XYZ ID”

  "name": "XYZ Name",

  "publisher": "XYZ Publisher",

  "version": "1.0.0.0",

  "brief": "",

  "description": "",

  "privacyStatement": "",

  "EULA": "",

  "help": "",

  "url": "",

  "logo": "",

  "dependencies": [],

  "screenshots": [],

  "platform": "17.0.0.0",

  "application": "17.0.0.0",

  "idRanges": [

    {

      "from": 60000,

      "to": 60049

    }

  ],

  "contextSensitiveHelpUrl": "XYZ URL”

  "showMyCode": true,

  "runtime": "6.0"

}

```

 

codeunit

```

codeunit 60002 XYZEvents

{

    trigger OnRun()

    begin

 

    end;

 

    [EventSubscriber(ObjectType::Table, Database::Customer, 'OnAfterValidateEvent', 'Payment Method Code', true, true)]

    local procedure XYZ_Customer_MethodPaymentCode_OnAfterValidate(var Rec: Record Customer)

    var

        SalesHeader: Record "Sales Header";

    begin

        **SalesHeader.SetRange("Sell-to Customer No.", Rec."No."); // breakpoint set here and every other line of code without effect**

        if SalesHeader.FindSet(true, false) then

            repeat

                SalesHeader.Validate("Payment Method Code", Rec."Payment Method Code");

                SalesHeader.Modify(true);

            until SalesHeader.Next() = 0;

    end;

 

    var

        myInt: Integer;

}

```

 

In the above codeunit, also went to Go to definition for “Sales Header”

Opened: table 36 "Sales Header", set breakpoint on InitInsert, with no effect.

 

```

trigger OnInsert()

    var

        O365SalesInvoiceMgmt: Codeunit "O365 Sales Invoice Mgmt";

        StandardCodesMgt: Codeunit "Standard Codes Mgt.";

    begin

        InitInsert;

        InsertMode := true;

 

        SetSellToCustomerFromFilter;

 

        if GetFilterContNo <> '' then

            Validate("Sell-to Contact No.", GetFilterContNo);

 

        Validate("Payment Instructions Id", O365SalesInvoiceMgmt.GetDefaultPaymentInstructionsId);

 

        if "Salesperson Code" = '' then

            SetDefaultSalesperson;

 

        if "Sell-to Customer No." <> '' then

            StandardCodesMgt.CheckCreateSalesRecurringLines(Rec);

 

        // Remove view filters so that the cards does not show filtered view notification

        SetView('');

    end;

 

```

**Expected behavior**

VS Code should stop on breakpoints and show elements in debugger side panel.

 

**Screenshots**

If applicable, add screenshots to help explain your problem.

1401.debug1.JPG

 

**5. Versions:**

<!-- Go to Visual Studio Code → Extensions panel → AL Language -->

**VS Code: Version: 1.51.1

AL Language: v6.1.362735**

<!-- In the client search for: System Information -->

**In BC Sandbox, using CRONUS USA, Inc.:

Application Version: 17.0.16993.0

Platform Version: 17.0**

I have the same question (0)
  • Suggested answer
    Marco Mels Profile Picture
    on at

    Hello,

    We currently do not have dedicated Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist.  If you need assistance with debugging or coding I would recommend discussing this on one of our communities.

    www.yammer.com/dynamicsnavdev

    dynamicsuser.net/.../developers

    I will open this up to the community in case they have something to add.

    Thanks.

  • Verified answer
    Andy365 Profile Picture
    80 on at

    Thanks Marco, will have a look at the links provided.

  • Andy365 Profile Picture
    80 on at

    This issue was resolved on the Dynamics 365 Business Central/NAV User Group Developers Forum (Help needed: The Vs Code debugger (AL code) does not work; does not stop on breakpoints).

    Apparently the issue revolved around web sessions. After clearing .alchache in VS Code and the browser cache, I also cleared the VS Code credentials cache and then canceled the session in Dynamics 365 Business Central admin center. I then signed in with new credentials, the app launched, and the debugger worked as expected.

    No other changes were made. Since then, non of the above steps taken seem necessary, and the debugger works after F5 and then calling the subscription as previously noted.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,135

#2
YUN ZHU Profile Picture

YUN ZHU 733 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 612

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans