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

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

Table lists which can have large number of records in Ax 2012

If you are facing database or application performance issue then you can check these tables that may have large number of records. ECORESPRODUCTVARIANTDIMENSIONVALUE INVENTBATCH ECORESPRODUCTMASTERDIMENSIONVALUE ECORESPRODUCTMASTERDIMENSIONVALUE ECORESPRODUCT ECORESPRODUCTTRANSLATION ECORESPRODUCT ECORESPRODUCTVARIANTDIMENSIONVALUE INVENTDIMCOMBINATION ECORESRELEASESESSIONPRODUCT ECORESRELEASEPRODUCTLEGALENTITY INVENTSUMLOGTTS INVENTCOSTLISTPARM GENERALJOURNALACCOUNTENTRY GENERALJOURNALACCOUNTENTRYZAKAT_SA SMMTRANSLOG LEDGERENTRYJOURNALIZING DIMENSIONFOCUSBALANCE MARKUPTRANS INVENTTRANSPOSTING INVENTREPORTDIMHISTORY SALESPARMLINE SOURCEDOCUMENTLINE INVENTTRANS TRANSACTIONLOG INVENTTRANSORIGIN INVENTSETTLEMENT SALESPARMSUBTABLE SALESPARMTABLE SOURCEDOCUMENTHEADER SALESPARMUPDATE SQLSYNCINFO GENERALJOURNALENTRY SUBLEDGERVOUCHERGENERALJOURNALENTRY CUSTSETTLEMENT SMMACTIVITYPARENTLINKTABLE INVENTSUMDATETRANS LEDGERTRANSSTATEMENTTMP DIMENSIONFOCUSLE...

Code to get Invoice settlement data for customer in ax 2012

This is simple Code to get Invoice settlement amount data for customer payment in ax 2012. This data is after posting of data. select sum(SettleAmountCur) from custSettlement where custSettlement.TransRecId == custtrans.RecId If you want get settlement amount before posting than you can refer spectrans table.The table SpecTrans contains all the transactions marked for settlement for payment journal. while select spectrans join custtransopen join custtrans where spectrans.SpecCompany == ledgerjournaltrans.DataAreaId && spectrans.SpecTableId == ledgerjournaltrans.TableId && spectrans.SpecRecId == ledgerjournaltrans.RecId && spectrans.RefCompany == custtranssopen.DataAreaId && spectrans.RefTableId == custtranssopen.TableId && spectrans.RefRecId == custtranssopen.RecId && custtransopen.RefRecId == custtrans.RecId && custtransopen.AccountNum == custtrans.AccountNum { info...