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 Send the Callstack to the Infolog


When troubleshooting a problem it is helpful to have the X++ callstack especially in scenarios where you cannot use the debugger in the environment or the issue happens sporadically. The following X++ code will retrieve the X++ callstack and send it to the infolog.  Add the example code to a method that is throwing an error or that you are otherwise concerned with.  Once you have finished troubleshooting the issue make sure you remove the example code from the existing X++ method.

container myCallStack;
int i;
str whatToWrite;

;

myCallStack = xSession::xppCallStack();
for(i=1; i<=conlen(myCallStack); i++)
{
    whatToWrite += conpeek(myCallStack, i);
}

info(whatToWrite);

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.