Skip to main content What is Dynamics 365? Guided tours Customer stories Try our products Build your own agents CRM ERP Sales Service Sales Customer Insights Customer Service Contact Center Field Service Supply Chain Management Commerce Finance Project Operations Human Resources Business Central Pricing Business application topics Training & certifications Documentation Migrate to the cloud Private equity Migrate to Dynamics 365 Events Dynamics 365 Blog Product updates Onboarding and implementation Community Find a partner Software Development Companies Partner resources Microsoft Marketplace Product documentation Technical support On-premises product support Contact us Try for free Sign in
1 min read

How to Identify the Tier X++ Code is Running On


It can be unclear as to which tier, either the client or the server, X++ code is executed on.  This ambiguity can lead to problems. For instance if you run a server-bound batch, all of the code has to run on the server.  If a call is attempted on the client this error will be thrown:  “The server-side impersonated (RunAs) session tried to invoke a method that is available for client-side processing only.”

You can add statements to your class that will tell you which tier your code is executing on.  Add the following to your X++ code:

info(strfmt("%1", xGlobal::clientKind()));

The output of this line will be either Client or Server.

Get started with Dynamics 365

Drive more efficiency, reduce costs, and create a hyperconnected business that links people, data, and processes across your organization—enabling every team to quickly adapt and innovate.