Hello,
I'm trying to create an invoice in the Dynamics AX database, using AIF services from a c# application.
I'm following this tutorial :
dev.goshoom.net/.../sales-orders-via-aif
with one obvious change :
- link shows how to create orders, for invoices I use a custom service based on a query using tables "CustInvoiceJour" and "CustInvoiceTrans"
It seems to work (no exception, after few attemps struggling with mandatory fields), but nothing happens : there is no row in tables "CustInvoiceJour" or "CustInvoiceTrans"
Can someone show me what I'm doing wrong ?
Or maybe it's simply not possible to create invoices from AIF services ? (if not, which is the best way to do that from a c# application ?)
Regards,
Charles
NB :
you will find below :
- the c# code
- the XML data (request and respond)
// header
var header = new AxdEntity_CustInvoiceJour();
header.OrderAccount = "[...]";
header.InvoiceAccount = "[...]";
header.SalesId = "[...]";
header.InvoiceDate = DateTime.Now.Date;
header.InvoiceId = "[...]";
header.CustomerRef = "[...]";
header.CurrencyCode = "[...]";
header.CustGroup = "[...]";
header.LanguageId = "[...]";
// line
var line = new AxdEntity_CustInvoiceTrans();
line.InventTransId = "[...]";
line.Qty = 3;
line.ItemId = "[...]";
line.ItemCodeId = null;
line.InvoiceId = "[...]";
line.InvoiceDate = DateTime.Now.Date;
// set lines on header
header.CustInvoiceTrans = new AxdEntity_CustInvoiceTrans[]
{
line
};
// set invoices list
var invList = new AxdCustomInvoice()
{
CustInvoiceJour = new AxdEntity_CustInvoiceJour[]
{
header
}
};
// context
var callContext = new CallContext() { Company = "our_company" };
// create
var key = client.create(callContext, invList);
// no exceptions here but nothing in the database
// value of "key" is :
// KeyData(){ Field = "RecId", Value = "0" }
Xml Data request :
<?xml version="1.0" encoding="UTF-8" ?>
- <MyCustomInvoiceServiceCreateRequest xmlns="http://tempuri.org">
- <MyCustomInvoice xmlns="schemas.microsoft.com/.../MyCustomInvoice">
<ClearNilFieldsOnUpdate>true</ClearNilFieldsOnUpdate>
<DocPurpose>Original</DocPurpose>
<SenderId xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
- <CustInvoiceJour class="entity">
<_DocumentHash xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<BankLCExportLine xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<BillOfLadingId xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<CashDiscCode xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<ContactPersonId xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<CurrencyCode>[...]</CurrencyCode>
<CustGroup>[...]</CustGroup>
<CustomerRef>[...]</CustomerRef>
<DeliveryName xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<DirectDebitMandate xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<DlvMode xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<DlvTerm xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<DocumentNum xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<DueDateTimeEinvoice xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<EInvoiceAccountCode xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<EnterpriseNumber xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<EUSalesList xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<InterCompanyCompanyId xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<InterCompanyPurchId xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<IntrastatDispatch xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<InventLocationId xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<InvoiceAccount>[...]</InvoiceAccount>
<InvoiceDate>[...]</InvoiceDate>
<InvoiceId>[...]</InvoiceId>
<InvoicingName xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<LanguageId>[...]</LanguageId>
<LedgerVoucher xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<LineSpecEinvoice xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<Log xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<MCREmail xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<NumberSequenceGroup xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<OrderAccount>[...]</OrderAccount>
<ParmId xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<PaymDayId xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<Payment xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<PaymentId xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<PaymentSched xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<PaymId xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<PostingProfile xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<PrintMgmtSiteId xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<PurchaseOrder xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<RCSalesList_UK xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<ReturnItemNum xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<ReturnReasonCodeId xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<SalesId>[...]</SalesId>
<SalesOriginId xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<TaxGroup xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<TaxInvoiceSalesId xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<TaxItemGroup xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<TaxTypeCodeEinvoice xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<TypeCodeEinvoice xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<VATNum xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<WorkerSalesTaker xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
- <CustInvoiceTrans class="entity">
<AssetBookId xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<AssetId xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<BillingCode xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<CountryRegionOfShipment xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<CurrencyCode xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<EInvoiceAccountCode xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<ExternalItemId xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<InterCompanyInventTransId xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<IntrastatDispatchId xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<InventDimId xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<InventRefId xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<InventRefTransId xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<InventTransId>[...]</InventTransId>
<InvoiceDate>[...]</InvoiceDate>
<InvoiceId>[...]</InvoiceId>
<ItemCodeId xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<ItemId>[...]</ItemId>
<ItemName xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<LedgerDimension xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<LineHeader xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<MCRDeliveryName xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<MCRDlvMode xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<Name xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<NumberSequenceGroup xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<OrigCountryRegionId xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<OrigSalesId xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<OrigState xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<Port xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<RetailCategory xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<ReturnDispositionCodeId xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<SalesCategory xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<SalesGroup xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<SalesId xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<SalesUnit xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<StatProcId xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<TaxGroup xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<TaxItemGroup xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<TaxWithholdGroup_TH xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<TaxWithholdItemGroupHeading_TH xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<TaxWriteCode xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<TransactionCode xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
<Transport xsi:nil="true" xmlns:xsi="www.w3.org/.../XMLSchema-instance" />
</CustInvoiceTrans>
</CustInvoiceJour>
</MyCustomInvoice>
</MyCustomInvoiceServiceCreateRequest>
Xml Data response :
<?xml version="1.0" encoding="UTF-8" ?>
- <MyCustomInvoiceServiceCreateResponse xmlns="http://tempuri.org">
- <EntityKeyList xmlns="schemas.microsoft.com/.../EntityKeyList">
- <EntityKey xmlns="schemas.microsoft.com/.../EntityKey">
- <KeyData>
- <KeyField>
<Field>RecId</Field>
<Value>0</Value>
</KeyField>
</KeyData>
</EntityKey>
</EntityKeyList>
</MyCustomInvoiceServiceCreateResponse>
*This post is locked for comments
I have the same question (0)