Tuesday, 30 December 2008
InfoPath Rich Text Display in Form: Expression Box
For whatever reason, I couldn't use the Rich Text Box control within InfoPath to display the data. Normally I would just use an expression box to display read-only data on the form, as it renders and resizes appropriately and looks seamless.
However - the expression box was just rendering the XHTML source code ("<div class="'....'">asfsdgf</div>....."). So - to force the expression box to render the source code 'properly', we have to open the view xsl source file, and modify the tag that renders the data. This is easier than it sounds:
1. Bind an expression box to your Rich text data source element
2. File -> Save as Source Files
3. Open the appropriate view.xsl file in notepad
4. Find your expression box in the markup. This will look like <xsl:value-of select="MyElement" />
5. Add the following parameter to the xsl:value of tag: disable-output-escaping="yes"
So the updated tag will read:
<xsl:value-of select="MyElement" disable-output-escaping="yes" /> (where "MyElement" is your data source element).
6. Save, close, open the manifest file up in InfoPath and presto - your Rich Text XHTML is rendered as HTML in the form rather than as plain text.
This bugged me for a while - so hopefully it might save some of you some time!
davros.
Thursday, 4 December 2008
InfoPath and Great Plains Web Services: Update Customer Address Sample
…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:
[WebMethod] // Set up the Web Service companyKey = new CompanyKey(); classIdRestriction = new LikeRestrictionOfString(); // Get a list of customers matching the above restrictions return custList; } |
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:
[WebMethod] |
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.
Conclusions
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?
- Customer Management?
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.
Resources
- 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
Cheers all:-
davros