Skip to main content

AIF document service through the wizard in MSDAX

AIF document service through the wizard (in AX). The service is meant for creation of a ProductionOrder. It is built on a query on the ProdTable and InventDim tables. It has ‘create’ and ‘read’ operations. The following is the screenshot of the list of classes generated and below is their descriptions:

AxProdTable - The class that represents the table ProdTable
AxInventDim_ProdTable - The class that represents the table InventDim
AxdProductionOrder2 – Document Class
ProductionOrder2 – Data Object class (the class that serializes/deserializes XML data for usage in the form of a object)
ProductionOrder2Service – the service class (which has ‘create’ and ‘read’ methods apart from others)

Its successfully deployed it as a web service on IIS and able to add it as a service reference in a C# application.  able to use the classes from AX (the service classes that are generated in AX on creation of the service)
following necessary code in C# to call the service and make use of the ‘create’ operation exposed by the service.


 using System;  
 using System.Collections.Generic;  
 using System.Linq;  
 using System.Text;  
 using System.Collections;  
 using finalProdOrder.AifReference;  
 namespace finalProdOrder  
 {  
 class Program  
 {  
 static void Main(string[] args)  
 {  
 // Instance of service client class.  
 ProdcutionOrder2ServiceClient service1 = new ProdcutionOrder2ServiceClient();  
 // Instance of document class.  
 AxdProdcutionOrder2 prodOrder = new AxdProdcutionOrder2();  
 // Instances of the entities(tables) that are used in the service and setting the needed fields on those entities.  
 AxdEntity_ProdTable prodTable = new AxdEntity_ProdTable();  
 prodTable.ProdId = "WO014117";  
 prodTable.ItemId = "00100400";  
 AxdEntity_InventDim inventDim = new AxdEntity_InventDim();  
 // Adding the sub-entity instances to their parent entities as an array of the sub-entity type.  
 prodTable.InventDim = new AxdEntity_InventDim[1] { inventDim };  
 prodOrder.ProdTable = new AxdEntity_ProdTable[1] { prodTable };  
 try  
 {  
 //Create method on the service passing in the document.  
 EntityKey[] prodOrderEntityKey = service1.create(prodOrder);  
 // The create method returns an EntityKey which contains the ID of the production order.  
 EntityKey returnedProdOrder = (EntityKey)prodOrderEntityKey.GetValue(0);  
 Console.WriteLine("A production order has been created with a Production ID of " + returnedProdOrder.KeyData[0].Value);  
 Console.ReadLine();  
 }  
 catch (Exception e)  
 {  
 Console.WriteLine(e.ToString());  
 Console.ReadLine();  
 }  
 }  
 }  
 }  
But when run this code, there is an exception while executing the service.create method(create operation). The exception shown in the Visual Studio console:
System.ServiceModel.FaultException`1[finalProdOrder.AifReference.AifFault]:Request Failed.

In AX (AIF), within Basic->Periodic->Application Integration Framework->Exceptions, the following is the exception:
Number sequence for the reference Lot ID in parameters in the Inventory management module has not been set up.

(P.S - From what to understand, this service is created on a query based on the ProdTable and InventDim tables. So, by creation of the production order, it is creation of a record in ProdTable, and not creation of a row in ProductionOrder form). The new record is being created without this “number sequence issue”. The number sequence for LotID is being generated successfully. But, the exception is showing up when we try to insert the record through the AIF service.

If  trying to modify the service classes (setInventTransID and parmInventTransID methods of the AxprodTable), in order to call the number sequence for Lot ID (InventTransID) but the same exception still exists. Please tell me if someone knows the exact classes that are to modified in order to successfully insert the data. Kindly help me out with this issue or please redirect me to someone that works/has worked on AIF.

Popular posts from this blog

strScan and Find a first occurrence of a string in a string using x++

strScan (Find a first occurrence of a string in a string) info("int strScan(str _text1,str _text2,int _position,int _number)"); info("Searches a text string for the occurrence of another string."); info("_text1 - The text string to search."); info("_text2 - The string to find."); info("_position - The position at which the search should start."); info("_number - The number of characters that should be searched."); info(int2str(strScan("ABCDEFGHIJ","DE",1,10)));

Code to get customer Primary Address in Ax 2012

Below Code to get customer Primary Address in Ax 2012. CustTable custTable_P; DirPartyTable dirPartyTable_P; DirPartyLocation dirPartyLocation_P; DirPartyLocationRole dirPartyLocationRole_P; LogisticsLocation logisticsLocation_P; LogisticsLocationRole logisticsLocationRole_P; LogisticsPostalAddress logisticsPostalAddress_P; LogisticsPostalAddress primaryAddress_P; while select custTable_P where custTable_P.AccountNum =='ED_01029' join dirPartyTable_P where dirPartyTable_P.RecId == custTable_P.Party join dirPartyLocation_P where dirPartyLocation_P.Party == custTable_P.Party && dirPartyLocation_P.IsPrimary==NoYes::Yes join dirPartyLocationRole_P where dirPartyLocationRole_P.PartyLocation == dirPartyLocation_P.RecId join logisticsLocationRole_P where logisticsLocationRole_P.RecId == dirPartyLocationRole

Get record from table on the basis of field id in Microsoft dynamics axapta x++

How to Get record from table on the basis of field id in dynamics axapta x++. just try following code in job to understand better way. emplTable emplTable; FieldId fieldId; ; fieldId = fieldNum(emplTable, Emplid); select emplTable; info(emplTable.(fieldId)); select emplTable where emplTable.(fieldId) == '1101'; info(emplTable.Name);