Get started developing in X++ with code examples
As a part of my job as a Customer Engineer, I deliver development workshops for Microsoft customers. Sometimes the workshops attendees don’t have any knowledge of X++ and want to have hands-on experience with the most fundamental concepts of this object-oriented language. As a response to this request I put together a VS project with code examples that illustrate the following X++ topics:
Topic |
Subtopic |
Code sample (Runnable class) |
Variables |
Constants |
ConstantValuesClass |
Composite Data Types |
Array |
ArrayClass2 |
Composite Data Types |
Container |
ContainersClass |
Key Operators |
Ternary ? Operator |
TernaryOperatorClass |
Control statements |
if...else |
IfStatementClass |
Control statements |
Switch Statements |
SwitchStatementClass |
Control statements |
While |
WhileLoopClass |
Control statements |
do..while |
doWhileClass |
Control statements |
For |
ForLoopClass |
Exception Handling |
Try, Catch, retry |
ExceptionhandlingClass |
Exception Handling |
Exceptions inside transactions |
ExceptionHandelingInSideTransClass |
Classes and objects |
Classes and objects |
CarClass |
Classes and objects |
Class Inheritance |
VehicleClass VehicleTrcukClass |
Classes and objects |
Subclass, Method Overriding |
OverridingExampleClass OverridingExampleSubClass
|
Database Access |
Select Statement |
SelectStatementClass |
Database Access |
While Select |
WhileSelectClass2 |
Database Access |
Joining |
JoinClass |
Database Access |
Inserting |
InsertClass |
Database Access |
Updating |
UpdateClass |
Database Access |
Deleting |
WhileSelectClass2 |
The project is available on GitHub. If you are learning X++ and you want to download and Import the code examples, please follow the next steps:
Download the project
1.In the lab environment, open a new browser session and navigate:
https://github.com/snikjou/D365FODevFoundations
2.Click the Clone or download button and select Download Zip.
3.Save the zip file to the Downloads folder and extract it.
Import the project
1.In Visual Studio, from the Dynamics 365 menu, select Import Project.
2. In the Import Project dialog, locate the file CodeExamples.axpp in the extracted folder and click OK
3. Check New solution to open the project. This imports the project into a new solution in Visual Studio.
4. Inspect the project in Solution Explorer.
Test the code examples
1. In the Solution Explorer, expand the Classes folder and select one of the runnable classes. For example, the class IfStatementClass
2. Right-click on the class and set it as the startup object for the project.
3. Press Ctrl-F5 or select Start without debugging from the Debug menu to execute the class.
4. The Runnable class IfStatementClass is a fully functional code example of how to utilize the If statement in X++.
For a list of services our Customer Engineer team offers for our Premier/Unified Support customers, please see Dynamics 365 Service Offerings. For more information please contact your Customer Success Account Manager (CSAM/TAM), Customer Engineer, or Microsoft representative.
WorkshopPLUS - Dynamics 365 for Finance and Operations: Development Foundations
WorkshopPLUS - Dynamics 365 for Finance and Operations: Advanced Development
Enjoy it
Acknowledgments: I want to thank my colleague Amy Flower (Customer Engineer) for her contributions and peer review.
*This post is locked for comments