Step by step how to create Number sequence.

For this demo, I will create New module, about creating Number Sequence without module is also same steps just leave some steps base on Design picture above

  1. Create ETD ContosoId extends num datatype.

  2. Create Contoso Table with ContosoId field.

  3. Create a new enum value Contoso in base ENUM NumberSeqModule.

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

We normally create action delete in foreign table to make sure referential integrity in Logic and validation.

The delete action has the following options: None, Restricted, Cascade, Cascade + Restricted

None:

This has no effect, and effectively disables the delete action. This is useful if you want to specifically state do nothing so that someone else doesn’t try to correct what seems to be an omission.

Restricted:

This will prevent the record from being deleted if there are records in the related table that match the selected relation. This occurs within the validateDelete table event, which is called by the delete table event.

Cascade:

This will delete the record in the related table, based on the relation. Ex: A sales order line is of no use without a sales order. This is an extension of the delete table event.

Cascade + Restricted

This is a little special. In a two-table scenario, it is the same as Restricted. It will stop the record from being deleted if a related record exists. But if the record is being deleted as part of a cascade from a table related to it, the records will be deleted.

for more infomation about how to create DeleteActions at MSDN.

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.

Solution

  • Write Custom AIF service to get Worker information, and then public this service.

  • Write C#.NET console to consume that service.

Walkthrough

Response class

[DataContractAttribute]
class MaxWorkerResponse
{
    str     gId;
    str     gName;
}

two value that I want to return is HcmPersonnelNumberId and HcmWorkerName, I will store it in 2 parms method

[DataMemberAttribute('HcmWorkerName')]
public HcmWorkerName parmName(HcmWorkerName _name = gName)
{
    gName = _name;

    return gName;
}

[DataMemberAttribute('HcmPersonnelNumberId')]
public HcmPersonnelNumberId parmId(HcmPersonnelNumberId _id = gId)
{
    gId = _id;

    return gId;
}

Service class

Create MaxPRService Class, This class consume through service that need to be extend SysOperationServiceBase class

class MaxPRService extends SysOperationServiceBase
{
}

Main logic

[SysEntryPointAttribute(true),
AifCollectionTypeAttribute('return', Types::String)]
public MaxWorkerResponse getEmployee()
{
    HcmWorkerRecId          workerRecId;
    HcmPersonnelNumberId    personnelNumber;
    HcmWorkerName           name;
    MaxWorkerResponse       response;

    workerRecId = DirPersonUser::currentWorker();
    personnelNumber = HcmWorker::find(workerRecId).PersonnelNumber;
    name = HcmWorker::find(workerRecId).name();
    
    response = new MaxWorkerResponse();
    
    response.parmId(personnelNumber);
    response.parmName(name);
    
    return response;
}

Create service

In AOT create new service and add recent created class to that Service, in operations node add getEmployee method, you will get something likes

Then right click service > Add-ins > Register Service.

go to AIF inbound form to create new service and add getEmployee operation to that service then Active.

Consume service

Add recent WSDL URI http://WINSERVER:8104/DynamicsAx/Services/MaxPurchReqGeneral into Service reference in C# Console project

static void Main(string[] args)
{
	CallContext context = new CallContext()
	{
		Company = "USMF",
		Language = "EN-US",
	};
	
	MaxPRServiceClient client = new MaxPRServiceClient();
	MaxWorkerResponse response = client.getEmployee(context);
	
	Console.WriteLine(response.HcmWorkerName + ", " + response.HcmPersonnelNumberId);
	Console.ReadLine();
}

Thank you for reading.

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

How to do

  • You need to make sure install web services component on Internet Information Services (IIS) and verify that the default website is working.

  • In AX, under System administrator > Services and AIF > Web sites, open from a create new record follow information

Name: DynamicsAXAif60 Virtual directory share path: \\YourServerName\MicrosoftDynamicsAXAif60 URL: http://YourServerName/MicrosoftDynamicsAXAif60

  • From now on, you can create AIF inbound port with HTTP adapter.

After you’ve actived the services, that Port will deployed under DynamicsAXAif60 folder in IIS.

Thank you for reading.

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

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

If you want to know more details, you have to go In Dynamics ax AIF Exceptions form then check

It’s quite hard for 3rd party developer, especially they don’t have right to access AX server.

Anyway, we can get meaningful error message by doing below steps

  • Check that box in AIF inbound ports

  • Use FaultException class to get message
try
{
	client.register(ctx, contract);
	Console.WriteLine("items registed on Trans Id: " + contract.InventTransId + " with " + contract.Qty + " quantities.");
	Console.ReadLine();

}
catch (System.ServiceModel.FaultException<ItemsRegistration.RegRef.AifFault> aifFault)
{
	//FaultMessageList[] list = aifFault.Detail.FaultMessageListArray[0];
	InfologMessage[] list = aifFault.Detail.InfologMessageList;

	foreach (InfologMessage message in list)
	{
		Console.WriteLine(message.Message);

	}
	Console.ReadLine();

}

what we got

Thank you for reading.