Walkthrough: Keeping it Simple with Customer Invoices and Dynamics AX AIF

Walkthrough: Keeping it Simple with Customer Invoices and Dynamics AX AIF

Seemingly complicated subjects can often have many simple day to day uses. Nowhere do I seem to see people overestimate complexity than with AIF. As an Architect, people are always surprised when I offer them simple AIF solutions to problems that they thought would take months to solve. It never ceases to amaze me. Of course things can get complicated fast, but a lot of day to day functionality can be utilized very easily. Let’s take a look at a classical example. I had some .NET developers walk up to me asking how to consume AIF services because they needed their external application to get invoice data from AX. So, I wrote them a quick 20 minute code example of how to consume an AIF service. As it turns out, they loved it. Later, some very experienced AX developers also loved it, and I was encouraged to make it into a blog post.. So, Wallah!!!!! For all of you wanting to see an example of how to utilize AIF for day to day functionality, here is an example of how to get invoice functionality.

First, use the Graphical User interface to “write” and expose a service. Ha..ha..ha..

One shocking part with many companies with just how easy it is to activate a default service. Default services are packed with functionality, and by simply clicking a button, you can utilize them.

System Administration
à
Setup
à
Inbound Ports

Second, create a new service

The two most important parts of a getting a service up and running (where functionality is concerned at least) are the name of the service aka ‘portname’. You can choose anything that you want for the portname but remember that external companies may be using this to consume code, so please remain professional.

[Special note of caution]: Try to make the name friendly because you will have to use it to do all the magical things for that service later and it’s embarrassing to tell a customer to connect to a service with a name like “Big Daddy” or something like that.

Now, here is where things get really easy. Simply, find the service that you want. Let’s say that you want to make it to where clients can read some value. Click on the service operations button shown above and drag and drop the SalesSalesInvoice Service.Read operation to the Selected Service Operations Node. This basically allows you to query any invoice that you want from an external application.
***********(Make sure that you bring in the “find” method so that you can use the QueryCriteria object later on)************

After choosing that, activate the port.. Remember the URL of the port as you will need this later.

Third, open up Visual Studio and Create a Service Reference

To make things simple, first create a simple console application project

Now, continuing to use wizards, right-click on the TestCustInvoiceService References and choose to add a service reference

Simply copy and paste the WSDL url from the service into the address field and hit “Go”. Be sure to give the namespace an important name because it will be important for code. Click “OK” when done.

Fourth, write the code in C sharp

Here is what many people miss. By simply exposing an AIF service, you can do a whole lot. The service makes the tables available to external applications. After that, use the language of love, QueryCriteria, to pull whatever you need. See the simple little script that I wrote from Csharp to utilize AIF without altering any inherent AX code.

And now, look at the results. You just learned how easy it is to take a service and pull the data you need for external applications, like if an application needed to pull invoice data from Dynamics AX!!!

So, what have we learned? There is a lot of functionality that you can get from AIF with just common day to day functions. Ax is loaded with a lot of functionality, and I’m always amazed at how often people forget this. But it is there and getting better with each version!

Have a good one!

Videos