Total Pageviews

Search This Blog

Friday, December 31, 2010

Contd..How to Add multiple Search Criteria using EWS

This is in continuation with the previous posts on integrating Dynamics AX with Exchange Web Services without installing Outlook on your box. If you missed the previous posts, you can browse them from here:

Had this requirement to add multiple search criterias for filtering emails based on different subjects. For this, I had to use the SearchFilterCollection method to achieve it, below is the code snippet on how to achieve it. The code is pretty self explanatory as the SearchFilterCollection object can handle logical operators like Or, And etc. and you can pass multiple SearchFilters to it as shown here.

If you want to delve more indepth, you can read the MSDN article below:

Wednesday, December 29, 2010

AIF Error creating the Web Proxy specified in the '' configuration section.

A small tip when you are working on Dynamics AX AIF Services running on VPC

A background - I have a very simple AIF .Net Client App which has been very handy for me to test AIF Services on any environment. This client app consumes the AIF Customer Service to create customer records in AX.


Recently, when I was trying to generate the proxy for one of the AIF Service which was running on a VPC I ran into this error below (Note the client app project was on my host machine and I was opening the VS project via the shared drive)
"Error creating the Web Proxy specified in the '' configuration section."


Copied the Visual Studio Client App Project into the VPC, Built it and re-generated the proxy for the service and now it works

Link to Dynamics AX Code Samples on MSDN

Dynamics AX Code Samples on MSDN, Just enter the search text "Dynamics AX" to do a search in the code gallery

Friday, December 24, 2010

Wishing you Merry Xmas and A Happy 2011

Wishing you all my blog readers Merry Xmas and A Very Happy 2011.

Dynamis AX Integration with QAS for Address Verification

QAS is a third party address verification service which gets the full address from a given postcode and street. You can find more details in their website
We had to do integration for Australian Post Codes and Street Addresses. So, we were given the web service by QAS which we needed to plug in to AX

Integration with Dynamics AX 
a. Consume the QAS Web Service by going through Tools > Development Tools > Application Integration Framework > Add Service Reference
b. Once the Service Reference is added, write a class to instantiate the proxy and pass the zip code and street name
c. Here is a sample code snippet which does the call to QAS and retreives the full address

We are calling this class from different forms like Customers, Sales Orders, CRM wherever we need to validate address with QAS

Thursday, December 23, 2010

Dynamics AX Troubleshooting AOS Error Internal Error occured executing stored procedure when creating session for the AOS


One of our AOS suddenly stopped working and it won't restart any more. Learned that there was a database refresh the last night.

The error I found in event viewer was  Object Server 01: Internal Error occured executing stored procedure when creating session for the AOS (Screenshot below)


Wednesday, December 15, 2010

[Updated] How to Debug Batch Jobs running on Dynamics AX 2009 with AOS Server on Windows Server 2008

I'm having a hard time debugging batch jobs on server, my batch job executes but it never hits the breakpoint.

I followed all the steps mentioned in this blog post

and additionally installed the hotfix as our AOS Server runs on Windows Server 2008, but still unable to hit the breakpoint.

Just wondering, if anybody out there has achieved success in debugging batch jobs on AOS Server (which runs Windows Server 2008)? If yes, would be glad if they can share their experiences or email me on maildotdilipnATgmaildotcom or put a comment below. Thanks

Thanks to all who replied me via emails and comments. Appreciate it.

Solution (If you debugging batch jobs on Windows Server 2008)

a. Make sure you have checked all the steps

b. Run the hotfix mentioned in the blog link above
c. Logon to your remote desktop using (mstsc /console)
d. Run the Debugger As Administrator i.e. right click AxDebug. exe and Run as Administrator.
Observation - It's not necessary to logon with the same account as your AOS Service account, I logged in with my network alias which happened to be the admin on the box and it worked well for me, Usually in strict environments we won't get access to the service account's password.
In my scenario, I missed Steps c and d. This is required if you run on Win Server 2008

Tip How to Encode URL for Dynamics AX 2009 Enterprise Portal Link


Some of our Enterprise Portal links which points to SSRS reports were not getting saved when we input it through "Manage Links" option when you edit the page via Sharepoint

For e.g. one of the link which gives the problem was http://servername/Reports/Pages/Report.aspx?ItemPath=%2fMAX+Reports%2fPromotions+Claims+Report+Rebates

When saved, it spits out an error saying "The URL Property is not well formed"


Replace the “+” character with “%20” (which is used for space) and that works like a charm!

[Updated] Code to read email using EWS (Exchange Web Services)

Thanks for all my blog readers as I got an overwhelming response for this post asking me for the code to connect using EWS and read email from Exchange Server

For starters, this is the Part 1 which gives a theoretical view of using EWS to read email without having Outlook Client on your AOS

This is all the code which does the job:

a. Declaration

b. Logic for reading the email for a particular email address and subject and downloading the attachment

As you have seen the code above is very self-explanatory as it calls the Exchange Service proxy to do a FindItems for the mailbox folder (Inbox) and for a particular subject.

The next part in code is where it loops through the item collection and if it finds an attachment for the message item, it will download the attachment to the path supplied.


a. I tried to directly invoke the code from AX by adding the Exchange Service Assembly to the Resources node in AOT, but I'm unable to marshall the complex types and generics between X++ and .Net, Also the class ContainsSubstring is an abstract implementation in .Net which I'm unable to get a handle via X++, so I had to write a custom .Net wrapper and then call this from X++.

b. The X++ code which invokes my custom .Net assembly works fine without any issues if it's run via a job or class or menu item but as soon as I put it in a batch it doesn't work. It just fails without any error log.

[Update] I was able to track the error (CLR Exception: "When making a request as an account that does not have a mailbox, you must specify the mailbox primary SMTP address for any distinguished folder Ids") which was caused due to impersonation as the batch job was running under the AOS Service account and not the mailbox account, once I wrote the impersonation code using System.Net.Credentials in my .Net code, it works now without any issues.

Saturday, December 11, 2010

How to Read email and download attachment from AX (AOS) without Installing Outlook Client and using EWS Exchange Web Services

Design Requirement

To meet one of our solution requirement, we had to built an interface in AX which should be able to read an email with a particular subject line and download the invoice attachment to do further processing and posting of the same.

I searched on the web and most of the existing solutions or blog posts are about AX Sending emails where AX Communicates to Microsoft Exchange Server and is tightly coupled with Outlook client to be installed on AOS or client.

In our server topology, our infrastructure/IT team at the client's place won't allow us to install any office tools on the server, thereby ruling out the option of installing Outlook Client on the server.


After some research, I found that EWS is the way to go. EWS stands for Exchange Web Services which is an extensible component for clients to connect to your Exchange Server and can read emails from a particular mailbox. Here are the steps:

a. Download EWS SDK by going to this url,
Note, we have a separate SDK for EWS 2010. I downloaded the above SDK as our client is still on Exchange Server 2007

b. Install the Exchange Service msi which copies the Exchange Web Service dll to C:\Program Files\Microsoft\Exchange folder

c. Retrieve this dll and copy to your assembly on the AOS Server. i.e. you can drag and drop this dll file into C:\Windows\assembly

d. Note that this assembly is a .Net assembly so for me the easiest way was to write a custom wrapper assembly in C# which consumes the Microsoft Exchange Web Service (i.e. the dll in step b)

e. Add this custom dll into your References node in AOT

f. Write a class in AX which invokes your custom assembly

g. In my scenario, all the code had to achieve is given the parameters of email id, subject and UNC path name (Network location), it looks up the Exchange Store, reads the email with that particular subject line and downloads the related invoice attachment and strips it to the folder location on the network

And all this achieved without any mess and just few lines of code. If anybody interested in code, feel free to write to me and I can send you the .cs file

Happy Dax'ing :)

Saturday, December 4, 2010

Dynamics AX 2009 New VM - November release

Couple of days back I tried to open my existing Dynamics AX VM to find that it expired on Nov 15.

Lachlan has put up a blog post about the new VM's which Microsoft has released here in this link

VM OS now comes in 3 flavors

a. Hyper-V with Windows Server 2008
b. VPC 2007 with Windows Server 2008
c. VPC 2007 with Windows Server 2003

You can jump to PartnerSource by clicking these links




Fiddler - Good tool to check EP web page, custom websites, performance and AIF Web services

Recently, I was evaluating some tools for troubleshooting performance related to EP web pages.

I just bumped upon this site to find some great tools for testing performance of webpages, websites, sharepoint sites etc.

Out of the links in the browser add-ons, I evaluated Fiddler and it's quite handy, after installation it sits quietly in the browser window and then each page you load, it will show you the statistics in terms of how much time each functionality took to load, like web controls, web menus etc.

Good handy tool for any website debugging, Also with AIF Web Services, it shows you the xml sent between calls.

Friday, December 3, 2010

Troubleshooting - AOS Restart

In Dynamics AX 2009, I modified an existing table to add 2 new fields, as usual I did a db synch on that table so that the table definition is updated.

Came back to my program  which is a class which populates this table. Somehow, the values were not getting populated in these 2 new fields. Whatever, I tried but the program (my class) simply doesn't update my two new fields. Even, I went to the extent of hard coding these field values, but still it doesn't put any values in the table for those two new fields. Went into debugger mode and watched the tables populating the fields properly but after the insert statement still the values for those 2 new fields are not updated.

After struggling for 30 mins, finally gave up and did an AOS restart and there you go! the values now get updated