I have created a C# class library that uses document services for SalesSalesOrderService to create a sales order (just the header) and then a separate class method that updates a salesorder by adding a sales line to an existing sales order. The class library is added to the AOT in AX, it deploys fine, the intellisense in AX works fine, etc. I get no errors.
The problem, however, is that nothing happens when I execute the code in my test job and the debugging doesn't make it to the infolog statement. I also tried debugging with VS by attaching to the AX process but it never goes into VS. I am perplexed as this seems to be pretty simple. If you need more information just let me know. Thanks in advance for any help.
Below is the code from the class library and the job code that I am executing. I am using .NET framework 4.5.1
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using ALTAIFIntegration.DEVERP7SalesOrders; namespace ALTAIFIntegration { public class Deverp7SalesOrders { public string createSOHeader(string company, string custAccount, string invAccount, string delName, string poFormNum, string city, string county, string state, string street, string zip, string countryRegionId) { var salesTableAddressRec = new AxdEntity_TableDlvAddr() { City = city, County = county, State = state, Street = street, ZipCode = zip, CountryRegionId = countryRegionId }; var salesTable = new AxdEntity_SalesTable() { CustAccount = custAccount, InvoiceAccount = invAccount, DeliveryName = delName, PurchOrderFormNum = poFormNum, ReceiptDateRequested = DateTime.Now.Date, SalesType = AxdEnum_SalesType.Sales, TableDlvAddr = new AxdEntity_TableDlvAddr[] { salesTableAddressRec } }; AxdSalesOrder newSalesOrder = new AxdSalesOrder() { SalesTable = new AxdEntity_SalesTable[] { salesTable } }; var callContext = new CallContext { Company = company }; var client = new SalesOrderServiceClient(); try { client.create(callContext, newSalesOrder); client.Close(); return "Created"; } catch { client.Abort(); return "Failed"; throw; } } private static EntityKey[] EntityKeyForSalesId(string salesId) { KeyField field = new KeyField() { Field = "SalesId", Value = salesId }; EntityKey key = new EntityKey() { KeyData = new[] { field } }; return new[] { key }; } public string addSOLine(string soId, string soItemId, decimal qty, string invColorId) { using (SalesOrderServiceClient client = new SalesOrderServiceClient()) { EntityKey[] entityKeyList = EntityKeyForSalesId(soId); // Retrieve the order to modify var order = client.read(new CallContext(), entityKeyList); var inventDim = new AxdEntity_InventDim() { InventColorId = invColorId }; var salesLineAddressRec = new AxdEntity_TableDlvAddr() { City = order.SalesTable[0].TableDlvAddr[0].City, County = order.SalesTable[0].TableDlvAddr[0].County, State = order.SalesTable[0].TableDlvAddr[0].State, Street = order.SalesTable[0].TableDlvAddr[0].Street, ZipCode = order.SalesTable[0].TableDlvAddr[0].ZipCode, CountryRegionId = order.SalesTable[0].TableDlvAddr[0].CountryRegionId }; var salesLine = new AxdEntity_SalesLine() { ItemId = soItemId, QtyOrdered = qty, action = AxdEnum_AxdEntityAction.create, actionSpecified = true, InventDim = new AxdEntity_InventDim[] { inventDim } }; var salesTable = new AxdEntity_SalesTable() { _DocumentHash = order.SalesTable[0]._DocumentHash, PurchOrderFormNum = order.SalesTable[0].PurchOrderFormNum, ReceiptDateRequested = order.SalesTable[0].ReceiptDateRequested, action = AxdEnum_AxdEntityAction.update, actionSpecified = true, SalesLine = new[] { salesLine } }; AxdSalesOrder newOrder = new AxdSalesOrder() { SalesTable = new[] { salesTable } }; try { // Update the order client.update(new CallContext(), entityKeyList, newOrder); return "Updated"; } catch (Exception) { return "Failed"; throw; } } } } }
*This post is locked for comments