Hi,
I have been going through AL code instruction through learn4d365.com. I have created a codeunit app and published it to a Business Central sandbox. It works as expected.
However, when I attempt to debug the AL code in VS Code, I have encountered issues with the debugger. The debugger does not break on breakpoints. The only result I have seen in the debugger is that the CALL STACK will sometimes show “RUNNING.”
Expected behavior: VS Code should stop on breakpoints and show elements (call stack, variables) in debugger side panel. In the training video this works, so not sure what I am missing or if it is an actual bug with VS Code / AL code / Business Central.
I have posted the issue on Microsoft/AL (GitHiub) – waiting for more feedback. As well, I posted the issue on Dynamics 365 Business Central Forum and was directed here, to the Dynamics 365 Business Central/NAV User Group.
Any feedback here is appreciated.
The files listed below (launch.json, app.json, codeunit, and settings.json) show what I am working with along with a screenshot of the debugger after the subscription is called. Confidential / private data has been obscured.
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
[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.”); // set breakpoint set here, and every other line of code without effect
Message(‘Change made to the Customer Card Payment Method Code’);
Count := 0;
if SalesHeader.FIND(’-’) then
repeat
Count := Count + 1;
until SalesHeader.NEXT = 0;
MESSAGE(Text000 + ‘%1’, Count);
Count := 0;
if SalesHeader.FindSet(true, false) then
repeat
Count := Count + 1;
MESSAGE(Text001 + Text002 + ‘%1’, Count);
SalesHeader.Validate(“Payment Method Code”, Rec.“Payment Method Code”);
SalesHeader.Modify(true);
until SalesHeader.Next() = 0;
end;
var
Count: Integer;
Text000: Label 'SalesHeader.FIND Count: ';
Text001: Label ‘Change to Sales Order or Credit Memo Payment Method Code’;
Text002: Label 'The Count: ';
}
As well, In the above codeunit, I 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;
settings.json
{
“workbench.iconTheme”: “vscode-icons”,
“telemetry.enableTelemetry”: false,
“telemetry.enableCrashReporter”: false,
“editor.renderControlCharacters”: false,
“files.autoSave”: “afterDelay”,
“editor.wordWrap”: “on”,
“workbench.colorTheme”: “Default Light+”,
“editor.selectionHighlight”: false,
“editor.occurrencesHighlight”: false,
“window.zoomLevel”: 0,
“spellright.documentTypes”: [
“markdown”,
“latex”,
“plaintext”
],
“spellright.ignoreFiles”: [
“/.gitignore",
"/.spellignore”
],
“spellright.language”: [
],
“spellright.languageContext”: {
},
“cSpell.userWords”: [
“Mgmt”,
“Packt”,
“Walkthrough”
],
“workbench.sideBar.location”: “left”,
“todo-tree.tree.showScanModeButton”: false,
“dashboard.projectData”: null,
“zenMode.centerLayout”: false,
“zenMode.fullScreen”: false,
“bdev-al-xml-doc.checkProcedureDocumentation”: true,
“al.enableCodeActions”: true,
“al.codeAnalyzers”: [
“${AppSourceCop}”,"${CodeCop}"
],
“editor.fontSize”: 12,
“editor.lineHeight”: 14,
“debug.allowBreakpointsEverywhere”: true,
“al.editorServicesLogLevel”: “Verbose”
}
debugger screenshot, after the subscription is called
Thanks for any feedback!