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 :

Dynamics 365 Business Central: be careful when using the OnCompanyOpen trigger

Stefano Demiliani Profile Picture Stefano Demiliani 37,166 Most Valuable Professional

Today I was helping a partner on discovering performance issues on its Dynamics 365 Business Central online tenant. When analyzing the telemetry data with Application Insights, we discovered a lot of Long Running Query signals (event id RT0005) linked to the OnCompanyOpen trigger.

So strange… until analyzing its installed per-tenant extensions, we discovered an extension with a code like the following:

This extension subscribes the OnCompanyOpen trigger and then adds a custom code for logging stuffs related to the user on custom tables. Please don’t do in this way if you need that!

The OnCompanyOpen trigger is executed every time a new session is opened and the session can be of different types:

  • Web Client
  • Desktop
  • Phone
  • Tablet
  • Web Services
  • Background
  • Child

This was the real issue! Not all sessions are related to user sessions, but some of them are related to web services, background tasks, job queues and so on. These types of sessions was the biggest part of sessions opened every day and that causes the performance issues. To fix the code, just remember to always check the client type:

Small tip, but that can save your life in the cloud


This was originally posted here.

Comments

*This post is locked for comments