Max Nguyen

This post is our own opinion and does not necessarily reflect the opinion or view of our companies or Microsoft.

How to create main menu in Dynamics AX 2012

All main entry points to the UI and reports are access though the menu structure. This is presented in three ways: the left-hand navigation pane, the content area, and the navigation bar (at the top of the client). The menu design is controlled from the Menus node in the AOT.

Each module will have a menu, which is created by adding a menu reference (or shortcut) to the main menu:

This matches the list of modules shown in the client’s left-hand navigation pane.

Number sequence farmework overview in Dynamics AX 2012

For this demo, I will create New module along with NumberSequence, about creating Number Sequence without module you also use same steps just leave some steps base on Design picture above.

ETD

Create ETD ContosoId extends num datatype.

Table

Create Contoso Table with ContosoId field.

Enum

Create a new enum value Contoso in BaseEnum NumberSeqModule.

This value will be used to link number sequence to the module and to restrict displayed number sequence by module in Form.

Handle AIF error messages in dynamics AX 2012 R3

Normally, when we consume AIF Service, we use this code like below to handle Error messages

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
try
{
	client.register(ctx, contract);
	Console.WriteLine("items registed on Trans Id: " + contract.InventTransId + " with " + contract.Qty + " quantities.");
	Console.ReadLine();
}
catch (Exception ex)
{
	Console.WriteLine(string.Format("Ex: {0}", ex.Message));
	Console.ReadLine();
}

If it cause error, message would return like this

/imagesposts/Handle-AIF-error-messages-in-dynamics-AX-2012-R3-1.png

How to create HTTP adapter port

We normally use NETTCP adapter for .NET system, It going to very easy to consume by.

As my experience, if we use NETTCP adapter for consuming by Java system, we will need add some extension or 3rd party due to binding and mismatch schema and of course client doesn’t want to do that either me.

So, my solution is creating HTTP adapter for Java, you can also use .NET system to consume HTTP adapter without any problems

Response in AIF custom service class

At the previous post I already show how to customize Response Value list in AIF Document standard service, today we will talk about response in Custom AIF service class.

We already know for Custom AIF service we actually need 2 classes, one is contract for data input and one is service to process a logic. With Response class, it’s literally same with contract class. They both hold parm value.

  • contract class gets parametters.

  • Response class sets return values.

Scenario

I want to get HcmPersonnelNumberId and HcmWorkerName of current userID on C#.NET application.

AIF Custom response value in Dynamics AX 2012 R3

For this demonstration, I use AIF service to create Sales order with SalesSalesOrderService and I gonna consume AIF using C#.NET.

Normally, in consume service application we handle return value by using EntityKeyList, EntityKey, KeyData[0].Value. And for Sales Order It will return Created SalesID.

Let’s take a look on AxdSalesOrder class. More about Axd class please prefer this.

Then go to createList method, this method will handle response value

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
public AifEntityKeyList createList(
    AifDocumentXml                  _xml,
    AifEndpointActionPolicyInfo     _actionPolicyInfo,
    AifConstraintListCollection     _constraintListCollection)
{
    AifEntityKeyList aifEntityKeyList;

    aifEntityKeyList = super(_xml, _actionPolicyInfo, _constraintListCollection);

    // Sales orders are committed - master planning explosion can be executed and confirmed dates be set
    this.postSalesOrderCreation(aifEntityKeyList);

    return aifEntityKeyList;
}

So, how about customer wants another meaning value beside SalesID likes InventTransId information in SalesLine table or another tables base on your requirement. To do that, we need to customize this method.