If you get lots of phone calls that the users can’t do anything because one single user is locking the table you quickly end up in a stressful situation. This entry will be about to how to solve the locking and hopefully find the user that created the lock.
Read the rest of this entry »ChangeCompany Command Is Dangerous
The function Rec.ChangeCompany has been around for quite some in Navision/Dynamics NAV/Business Central. It is quite useful since it allows the user to quickly switch between companies and do record modifications in another companies in the same database. However, this is a very dangerous command especially now when events has been introduced. The question is if this command is still relevant today or if it should be passed to the cemetery.
Read the rest of this entry »How to Find a User From the User Telemetry ID
In my previous log entry I described how to find activity for a specific user in telemetry from Microsoft Business Central. This entry will be about doing the opposite, having a User Telemetry ID and then try to find which user it belongs to. The solution to this varies depending on which Business Central version you are running and which platform.
Read the rest of this entry »How To Show Business Central Server Information In Telemetry
In Business Central it is standard to not show server specific information in telemetry. The reason for this is that many run the SaaS version which makes server information irrelevant since the end users don’t need to care about server information. However, some us still have customers that run OnPrem which this information can be quite useful. One of our customers has multiple servers with job queues activated on all of them. One way of troubleshooting job queues is to look at if a certain server is the source of problem and to do that we need server information in the telemetry.
In this blog entry I will explain how you can create your own telemetry message that send the job queue entry status and server information to application insights.
AL0000G7I – Multiple custom dimensions with the same dimension name provided.
There is a telemetry event Id called: AL0000G7I – Multiple custom dimensions with the same dimension name provided.
Currently (2023-12-15) this event hasn’t been documented in the offical page for telemetry events.
The reason for the error can seem pretty straightforward. Probably you have added the same dimension twice to the dimension dictionary.
However, this wasn’t the scenario in my case.
There is a function that you can add telemetry dimensions that should be appended to ALL telemetry events (from the current app).
In codeunit 8706 “Telemetry Custom Dimensions”, you can subscribe to the event OnAddCommonCustomDimensions and from that you can append custom dimensions.
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Telemetry Custom Dimensions", OnAddCommonCustomDimensions, '', false, false)]
local procedure OnAddCommonCustomDimensions(sender: Codeunit "Telemetry Custom Dimensions")
begin
sender.AddCommonCustomDimension('ServerInstanceID', format(Database.ServiceInstanceId()));
sender.AddCommonCustomDimension('ServerInstanceName', GetServerInstanceName());
sender.AddCommonCustomDimension('ServerName', GetServerName());
end;
And as you probably you have understood by now it was here that I got the error with the same dimensions. I tried to log send the dimension ServerName multiple times.
And there it is, I hope it solved your error.
Snapshot debugging against sandbox
This was the first time I was going to debug against a sandbox it it wasn’t as smooth as I thought as it was with OnPrem. The reason for that is that the user id must be the GUID for the user name in BC.
First step is adding a new snapshot configuration for cloud in launch.json
This gives you the following
{
"name": "snapshotInitialize: Microsoft production cloud",
"type": "al",
"request": "snapshotInitialize",
"environmentType": "Production",
"environmentName": "production",
"breakOnNext": "WebClient",
"executionContext": "DebugAndProfile"
},
Now we need to change the environmentType if it is production we would like to debug. We also need to change enviromentName to the same name as the sandbox.
To be on safe side we could add the tenant property which is the id in the url string between dynnamics.com and sandbox name.
https://businesscentral.dynamics.com/<tenantId>/<sandboxName>
If you try go initialize snapshot you should get this (CTRL+Shift + P, AL: Initialize snapshot debugging, or press F7):
[2023-10-12 13:02:58.05] Initializing a snapshot debugging request on debugging context :5041bba9-6353-4cd9-b5d1-24e6168637ef
[2023-10-12 13:02:58.05] Sending request to https://api.businesscentral.dynamics.com/v2.0/<SandboxName>/snapshotdebugger/attach?debuggingcontext=5041bba9-6353-4cd9-b5d1-24e6168637ef
[2023-10-12 13:02:58.53] The snapshot debugger initialize request for the debugging context '5041bba9-6353-4cd9-b5d1-24e6168637ef' has succeeded.
Check the status of an initialized snapshot by using the 'Show all snapshots' command, or by clicking the snapshot debugger icon in the left corner of the toolbar.
First time you may need to create a link between your account and the tenant by authorizing yourself.
REMEMBER! If when you debug it is important that you have downloaded the same symbols that exists in the target machine or the debugging won’t work. So once you have established connection to sandbox. Choose download all symbols
Once you have verified you have connection you can add userID and session id to whom you would like to connect the snapshot debugger to.
{
"name": "snapshotInitialize: Microsoft production cloud",
"type": "al",
"request": "snapshotInitialize",
"environmentType": "Sandbox",
"environmentName": "<SandboxName>",
"breakOnNext": "WebClient",
"executionContext": "DebugAndProfile",
"userId": "<UserGuidInBC>",
"sessionId": -1
},
To get the userID when connecting to a sandbox you need to open Users in Business Central and “Zoom” by opening the page inspection for that user record and copy the “User Security ID”.
You get the session id by opening the “Question mark”/Help, choose “Help & Support”, go down to Report a problem and there you will find “Session ID (server)” which has the id to the user you would like to record/snapshot. Copy that to the sessionId in launch.json.
Now launch the initialize snapshot debugger again. The result should be something like this if you have done it right. After that, do the thing and choose finish snapshot when you are done.
[2023-10-12 13:33:45.48] Initializing a snapshot debugging request on debugging context :77d****-****-****-****-****
[2023-10-12 13:33:45.48] Sending request to https://api.businesscentral.dynamics.com/v2.0/****/snapshotdebugger/attach?debuggingcontext=****-ac67-****-bcef-****f3c&sessionid=31500&userid=****-****-****-****-****
[2023-10-12 13:33:45.92] The snapshot debugger initialize request for the debugging context '****-****-****-****-****' has succeeded.
Check the status of an initialized snapshot by using the 'Show all snapshots' command, or by clicking the snapshot debugger icon in the left corner of the toolbar.
If you get something like this it is because you haven’t filled in the Guid for the user.
[2023-10-12 13:40:24.63] Initializing a snapshot debugging request on debugging context :****-****-****-****-****
[2023-10-12 13:40:24.64] Sending request to https://api.businesscentral.dynamics.com/v2.0/****/snapshotdebugger/attach?debuggingcontext=****-****-****-****&sessionid=31500&userid=user%40company.com
[2023-10-12 13:40:26.31] The request for path /v2.0/EQM/snapshotdebugger/attach?debuggingcontext=****-6fbf-****-****-****&sessionid=31500&userid=user%40company.com failed with code BadRequest. Reason: The snapshot debugging session could not be started. The user GUID 'user@company.com' is not valid.
When does xrec work?
As a Business Central developer we have from time to got used to using xrec and rec as container for previous value and current new value.
However, there are certain scenarios when xrec doesn’t work as intended.
Read the rest of this entry »