web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :

Get started developing in X++ with code examples

Said Nikjou Profile Picture Said Nikjou 251

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.
pastedimage1603831060938v1.png

3.Save the zip file to the Downloads folder and extract it.
pastedimage1603831098591v2.png

Import the project

1.In Visual Studio, from the Dynamics 365 menu, select Import Project.

pastedimage1603831188174v4.png

2. In the Import Project dialog, locate the file CodeExamples.axpp in the extracted folder and click OK

pastedimage1603831215342v5.png

3. Check New solution to open the project. This imports the project into a new solution in Visual Studio.

pastedimage1603831242549v6.png

4. Inspect the project in Solution Explorer.

pastedimage1603831272203v7.png

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.

pastedimage1603831307560v8.png

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++.

pastedimage1603831339134v9.png

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.

Comments

*This post is locked for comments