microsoft-dynamics-ax-windows-8-app-starter-kit-development-guide
microsoft-dynamics-ax-windows-8-app-starter-kit-development-guide
Before you get started on building your first Dynamics AX app for Windows 8, you will need to setup
your development environment.
Windows 8
Visual Studio Express 2012 and Blend for Visual Studio
Dynamics AX 2012
In addition to development tools, a developer license is required to develop and test Windows Store
apps. The license is free and Visual studio will walk you through the process of getting a license.
More information about developer licenses can be found here.
Before we get started on developing our Dynamics AX app for Windows 8, we must first do some
planning. For our first app we will build a companion app that allows Dynamics AX users to take
action on Work list notifications.
First we must determine the scope of our app and define the experience goals that will guide us
through the rest of the design process.
To get started let’s make a list of the functionality we want our app to provide to users:
Now that we have an idea of what our app will do, we need to determine our app’s “great at”
statement.
Examples:
My Work list app is great at helping Dynamics AX users stay connected to their business
My Work list app is great at helping Dynamics AX users quickly take action on items
requiring their attention
My Work list app is great at providing decision makers with timely information
With our “great at” statement determined we must now create user flows. The flow represents a
set of related interactions that users have with the app to achieve their goals. The flows should be
easy to learn and require the fewest interactions possible.
First we must create a list of the flows for our app. Our Work list app is “great at helping Dynamics
AX users take action on items requiring their attention.” So some of the flows we will want to
highlight are:
Once we have determined what our app will do, we need to take a look at features available in the
Windows 8 platform that we want to include. We also need to ensure that each feature
implemented aligns with the Windows 8 user experience (UX) guidelines.
App Contracts
Our Dynamics AX app can participate in app contracts that enable broad, cross-app, cross-feature
user flows.
Features we will want to include with our Work list App are:
Search – Let users search through Work list items from anywhere in the system, including
from within other apps.
Share – Let users share Work list item information via email
Background tasks (Extension) – Let the app retrieve notifications from Dynamics AX even
when the app is suspended
Settings – Provide quick in-context access to settings. For example the connection
information required to synchronize with Dynamics AX.
Detailed information on App contracts and extensions available may be found here
Windows 8 apps by be used on many different form factors with different inputs. In planning the
design of the app it will be important to ensure that the user experience is good on both touch and
non-touch devices.
Once you have completed the planning phase, it will be time to get started with development. In
this guide we will walk through building a simple App to help you get started with building your
own Windows 8 apps that integrate with Dynamics AX 2012.
In order to access data in your Windows 8 App, an AIF service will need to be available to
reference. In this example we will build a Windows 8 app that allows a user to view their worklist.
First, we need to create a service that exposes the worklist. To begin we need a query which can
be used to base the service. Luckily a query already exists in the AOT that will meet our needs. The
query is: EventAlertForUser
4. Once your selections have been made, generate the service classes.
10. Under the troubleshooting tab set the logging mode to: All document versions. This will help in
case you need to investigate any issues with the service.
11. Once the service is configured activate it using the Activate button. (This may take a few
minutes depending on the speed of your environment).
13. If you are developing with the Dynamics AX 2012 R2 Demo VM 1.5 image, the address
generated for the web service is:
http://ax2012r2a:89/MicrosoftDynamicsAXAif60/WorkListService/xppservice.svc
By following the link the following webpage should display in your web browser:
3.2 Step 2- Create a new Windows Store App Project in Visual Studio 2012
Open up Microsoft Visual Studio 2012 and select the Split App (XAML) template under Visual C# ->
Windows Store.
Upon the initial creation of the project the solution structure should have the following items:
References – this is where we will create a reference to the Dynamics AX web service that
was created earlier.
Assets – Any images we want to use in our app will be stored here.
DataModel – In the example we will leverage the sample data model.
App.xaml – App resources such as the AppName can be found here.
ItemsPage.xaml – we’ll update the look of this page in Blend.
Package.appxmanifest – This holds the properties of the apps deployment package.
Let’s get started by making a couple changes to the appxmanifest. Right click on the appxmanifest
and open it up.
From the Application UI page we can set the name for are App, supported rotations, and logos.
Enterprise Authentication
Private Networks (Client & Server)
Let’s get started with wiring up our new Windows 8 App to Dynamics AX. First we will need to
create a service reference. Since Dynamics AX creates services based on WCF this is very
straight forward within Visual Studio.
1. Right click on References from the Solution Explorer and select Add Service Reference.
2. Enter the following address into the form and hit the Go button:
http://ax2012r2a.contoso.com:89/MicrosoftDynamicsAXAif60/WorkListService/xppservice.s
vc
The two operations that were enabled earlier within Dynamics AX should be visible.
Name the service WorkListService and hit OK.
Now that are app is connected to the Dynamics AX AIF web service, we’re ready to start consuming
data.
We’ll also need an instance of FindResponse object for the data we’ll get back from the service.
2. For our method we need to use an asynchronous call. Windows 8 Apps are take full advantage
of threading and asynchronous programming.
You notice that this method was created as an async Task and it returns a List. The service call
must be performed asynchronously so the method must be defined as async. If you are new to
asynchronous programming I recommend reading the following article on MSDN: Asynchronous
Programming with Async and Await (C# and Visual Basic).
4. With the query objects created, we can now set the criteria values.
It is important to set the DataSourceName correctly. This must be provided for the query to
function.
5. Once the criteria has been set the find operation may be executed.
6. Once data can come back from the service we will iterate through it and put it in a generic list
collection.
For the purposes of this example only the Alert worklist messages will be utilized.
We now have data from Dynamics AX 2012 in our Windows 8 app. For this example I am going
to re-use the SampleDataSource that was created with our template project.
1. The data has to be synced on an async event. For this example, the call to AX AIF web
service has been added to LayoutAwarePage.cs. The method is OnNavigatedTo , this is
invoked when a page is about to be displayed in a frame.
Before the OnNavigatedTo method can be used to call the service we must turn it into an
async method.
2. The following code is added to the OnNaviagedTo method to refresh the data.
To temporarily store data a new class was created named AXDataSource. This simple class
has a static List which is used to store the workListItems.
By default the SampleDataSource creates hard coded sample data in the classes
constructor: SampleDataSource(). For the example we will populate the first item group
with Alert worklist messages from Dynamics AX.
The SampleDataSource may be useful for creating proof of concept Windows 8 Apps. The
other groups may be easily manipulated since they are built from hard coded data.
The first item group should now display Alerts and the number of messages that were
retrieved from Dynamics AX. Note that since the call to query the web service is using
await, the items will not display until data has been retrieved.
At this point message data from Dynamics AX 2012 for alert worklist items will appear.
Many of the alert messages lack a message body; the App is only as good as the data.
Next we will take a quick look at some ways to quickly change the look and feel of your
Windows 8 app with Blend.
1. Open the example solution in Blend by right clicking on the solution from Solution Explorer
and selecting Open in Blend.
3. For my example Windows 8 app, I wish to apply a standard background to all of my Apps
pages. To do this I need to modify my resource dictionary which is defined in the App.xaml
file.
Set the background property to an image you wish to have displayed. By default any
images used by your app should be saved to the projects Assets folder.
5. Next let’s take a look at how to modify the default template used to create new items in
the grid view. Right click on the ItemsPage.xaml ItemGridView control from design view in
Blend. Select Edit Additional Templates -> Edit Generated items (ItemTemplates)->Edit
Current
5. Conclusion
In this guide we have walked though creating a simple Windows 8 App that integrates with
Dynamics AX 2012 R2. Due to the use of the Windows Communication Foundation (WCF),
accessing data from Dynamics AX 2012 is simple to do.
Windows 8 provides a wonderful new opportunity to build engaging solutions that work great
on many different device form factors. This allows users to interact with their data from
applications such as Dynamics AX in many new and exciting ways.
Have fun building your Windows 8 Apps and be sure to check for the latest version of the
Dynamics AX Windows 8 App Starter Kit on CodePlex.