This week I was asked to explore some the new web services available out the box with GP 10.0. It seems there are services to do pretty much anything you want with GP (Programmers Guide: https://mbs.microsoft.com/downloads/customer/WSProgrammersGuide.pdf). I thought I’d use some to create an InfoPath form to update customer details in GP. I had a dig around on the web, but didn’t find any examples of InfoPath being used with these services, which seemed strange…
…until I found that alas – they are not InfoPath ‘friendly’. Because of the way these services work it becomes necessary to create a middle tier web service ourselves, between the form and the GP web services.
[This posting is not a run-down of the web services in GP (see the above programmers guide for that). Instead it should serve as a starting point to show how we can use InfoPath to interact with GP data.]
Creating Our Web Service
Create a new Web Service project in Visual Studio
Add a Web Reference to the Dynamics GP Web Service. (Usually under /DynamicsGPWebServices/DynamicsGPService.asmx)
Now create our required Get and Set Web Methods (see code sample below)
Get Customer List:
// Set up the Web Service
companyKey = new CompanyKey();
classIdRestriction = new LikeRestrictionOfString();
// Get a list of customers matching the above restrictions
Despite this method returning a custom array of customers, this renders through the web service as XML, and InfoPath is quite happy to pick up the fields. Below is the data set seen after connecting to my new web method in InfoPath (left).
This data populates a drop down list box in InfoPath. After selecting a customer and address, I want the user to be able to update the address and submit back to my web service – which in turn formats the data and calls the GP Web Service.
The method shown below either adds a new customer address, or updates an existing one:
custAddress.Line1 = line1;
Now all that needs to be done is to hook up my Add / Update method to my InfoPath form. I chose to add it as a query web service – as it returns a Boolean result that I can check in the form to show success or failure.
And Presto – An InfoPath 2007 form getting and updating data in GP 10. Of course, there is no reason now why we can’t publish the form to InfoPath Forms Services.
As for business use – this method can be highly useful, as we can allow other non-GP staff to interact with the system. With further customization, it could suit the following scenarios:
- Expenses Form?
Stock Item Creation?
And of course, as we are using InfoPath if we hook into SharePoint too we can create approval processes for these forms to be approved before they are submitted to GP.
- Web Service Programmers Guide (pdf): https://mbs.microsoft.com/downloads/customer/WSProgrammersGuide.pdf
- Dynamics Web Service SDK (with sample windows app): https://mbs.microsoft.com/downloads/customer/DynamicsGPWebServicesSDKv9.msi