AIF: Sales invoice service

salesinvoicenew.SalesInvoiceServiceClient client = new salesinvoicenew.SalesInvoiceServiceClient();
salesinvoicenew.CallContext callcontext = new salesinvoicenew.CallContext();
salesinvoicenew.AxdSalesInvoice invoice = new salesinvoicenew.AxdSalesInvoice();

callcontext.Company = “ceu”;
callcontext.Language = “en-us”;

QueryCriteria qc = new QueryCriteria();
qc.CriteriaElement = new CriteriaElement[1];
qc.CriteriaElement[0] = new CriteriaElement();
qc.CriteriaElement[0].DataSourceName = “CustInvoiceJour”;
qc.CriteriaElement[0].FieldName = “SalesId”;
qc.CriteriaElement[0].Operator = Operator.Equal;
qc.CriteriaElement[0].Value1 = “SO-101281”;

try
{
invoice = client.find(callcontext, qc);
Console.Write(“success”);
Console.ReadLine();
}
catch(Exception ex)
{
Console.Write(ex);
}

The above code is for sales order invoice find. I am new to ax … My project is to find values from sales table. i have written above code but dono what to do next. Pls guide me .

Could you please make your code more readable and change the title from “Dynamics Ax.” to something more descriptive? Also, what functionality are you trying to implement and what’s the part you need a help with?

I have created sales order using AIF service in C #. Now i want to create invoice for my sales order. Similarly i Used AIF service and created service reference and for my salesorderinvoice and used above code. I dono exactly how above code will give solution and i dono where to check my invoice for. let me attach my sales order creation code also. For the below code please show to create salesorder invoice.

salesorderservice.SalesOrderServiceClient client = new salesorderservice.SalesOrderServiceClient();

salesorderservice.AxdSalesOrder salesorder = new salesorderservice.AxdSalesOrder();

salesorderservice.CallContext callcontext = new salesorderservice.CallContext();

salesorderservice.EntityKey[] keys;

salesorderservice.EntityKey key = new EntityKey();

salesorderservice.KeyField fld = new KeyField();

salesorderservice.AxdEntity_SalesTable salestable = new salesorderservice.AxdEntity_SalesTable();

salestable.CustAccount = “1301”;

salestable.PurchOrderFormNum = “PO”;

salestable.ReceiptDateRequested = System.DateTime.Today;

salestable.CurrencyCode = “USD”;

salestable.DeliveryDate = System.DateTime.Today;

salestable.Payment = “N030”;

salestable.DlvMode = “10”;

salesorderservice.AxdEntity_SalesLine salesline = new salesorderservice.AxdEntity_SalesLine();

salesline.ItemId = “1000”;

salesline.SalesQty = 5;

salesline.SalesUnit = “ea”;

salesline.SalesPrice = 2000;

salestable.SalesLine = new salesorderservice.AxdEntity_SalesLine[] { salesline };

salesorder.SalesTable = new salesorderservice.AxdEntity_SalesTable[] { salestable };

callcontext.Company = “ceu”;

callcontext.Language = “en-us”;

try

{

keys = client.create(callcontext, salesorder);

Console.WriteLine(“sales order created”);

Console.Read();

}

catch (Exception e)

{

Console.WriteLine(“Exception issue”);

}

The above code for salesorder successfully for invoice guide me .

I want for salesorderinvoice find method

I restructured the code in the original post and changed thread name to include the problem area.

I still don’t understand what’s you need - hopefully you’ll have more luck with somebody else.

Hi Martin,

Abishek want to create a AIF service for Sales Invoice, So that he can use that service WSDL URL to his .NET created application to directly create Sales Invoice for any create Sales order.

He also created a Sales order AIF service and by using this he was able to create Sales order from .NET created application.

Actually I am also implementing same functionality I also have created .NET application for directly creating Sales order into AX by using Sales Order Standard service available.

Now, I want to do the Invoice of that created sales order or any sales order in AX. but there is no standard AIF service available with AX 2012.

So Can you tell me how I can create customize sales invoice AIF service in AX 2012. and which Tables do I need to use for creating this AIF service.

regards,

Sumit

Hi Sumit,

In Ax 2012 standard SalesInvoice service is there in AOT → Service node called “SalesSalesInvoiceService” . So add this service into Inboundport and activate the port.

Then adda that WSDL servie to your .net project.

Regards,

Abbas

Existing services don’t allow you to insert data to invoice journal tables because that’s something you shouldn’t do. You need to call the posting process (that inserts data to general ledger, tax tables etc.). Consider creating a custom service for that (= not a document service).

Hi Abbas,

It is outbound service. This service not allowed us to insert data into AX. Is there any other way to please tell.

regards,

Sumit

Hi Martin,

Can you tell me how can I call posting process. Or how can I create custom service. Which tables I have to use for creating this custom service. Or is there any other way to do this.

Thank you

regards,

Sumit

You really could do it by yourself: http://lmgtfy.com/?q=ax+2012+custom+service. Custom services allow you calling AX business logic, such as the standard invoice posting written in X++.

Nevertheless I realized that you don’t have to create a new custom service - it’s already there. See the FormletterService and its operation called postSalesOrderInvoice.

Thank you Martin,

I did that by using FormLetterService.