Writing your first X++ "Hello Word!" program

maqk® by MolviDSLR Khan | 5:44 PM

Programming the forms is not all too different in Dynamics as in in Visual Studio. Of course VS is a generic tool whereas MorphX (Dynamics IDE) is only specific to Dynamics.

But again the point is that too many things could have been similar, yet they are different for some purpose. And to learn those purpose is the real learning goal.

In MorphX, the world is squeezed into AOT (Application Object Tree). This features all tables, forms, EDTs, Classes, Menus, Items etc. So if you just wanna try out some basics X++ syntax, then Jobs is the right node for you.
  Image Hosted by ImageShack.us

This would enable you to test anything the X++ language offers under the dynamics framework. For example, you can display a simple "Hello Dynamics World!" message box,   you can iterate a whole DirParty table. You can even delete records, do further business operations whatever. Image Hosted by ImageShack.us

Creating a Sample Job

By right clicking the job node, you get the context menu. Click New Job. This would open a new sub window with a static method

Hitting F5 would run / start the job. For the above job, the output is attached just below;

As you can see, a few table names are returned. One thing to note is that one dialog / message box is showing all the messages displayed in the job, eliminating the one by one re appearing of a new message box for each :)

The code in the attached snap is as follows;

smmProcessInstance objsmmProcessInstance= new smmProcessInstance();


Their are 9 distinct calls to the info method, each calling another method, 'tableId2Name()' which takes table Id as parameter. I have provided hard coded table IDs their. Actually I was trying to find out what these tables are since these table IDs were referenced along with record reference Id field. These are Rec id based relations, an advanced topic that we will discuss in some other post.

Create a new Job, this will give you an empty 'static void Job1(Args _args)' method. Write inside the code

info("Hello Dynamics World!");

and Hit F5, You will get the message box with the above written text. Welcome to Dynamics coding :D


Santosh kumar Singh said...

This is good technical blog which is good for new dynamics learner and problem's solutions

Axapta ERP Technical blog-ALL Version

Post a Comment