How to debug on Business Central cloud version
Some "disclaimer" at the beginning.
Business Central change/improve every month.
I will provide below the today status for the 'Debug area' (October 2019).
// for example, in November we expect such feature:
Well … You cannot attach a debugger session to a production environment. You need to create a sandbox by copying the production data and then debug the sandbox environment.
As first step I go to my Business Central Admin Center, I’ve created a sandbox environment with copy of Production data for some specific date.
// By the way today you can have 3 Sandbox and 3 Production Business Central environments in an AAD tenant.
Open the sandbox environment and create a dummy extension via Designer option.
I am using such way just for fast creation of the AL project (.json files).
For launch.json add:
"breakOnError": true,
"sandboxName": "GBSandboxCopy25Oct2019"
For app.json increase version number:
AL: Download Symbols
Now we need create a let say ‘Debug codeunit’ (extension).
Our ‘Debug codeunit’ (extension) will subscribed to the posting codeunit.
For the today I see that System (Cloud BC) stop on break point that added in extensions only.
Now create a line in Item Journal, start Event Recorder, pick right lines with filter
// With Cloud you must use the closest point to hook within an extension to debug.
Copy signature for the subscriber function from Event Recorder:
Rename MyProcedure
Go to Definition, as result we could see Posting code, copy parameters from IntegrationEvent
Add Breakpoints to the ‘Debug codeunit’ (extension)
Stop a bit. We are not Publish our extension yet. Let’s do it.
Start Debugging:
P.S.
Useful Links (BC/NAV): https://community.dynamics.com/business/f/dynamics-365-business-central-forum/307965/info-useful-links