Tuesday, January 30, 2007
Web services are completely integrated in InfoPath 2003/2007. We can submit and retrieve data whenever we want. If the current InfoPath functionalities does not satisfy your manager's ideas, you can improve your forms with custom code. Today I show you how to integrate web services by using the InfoPath 2007 Object Model
Actually, the way you used the Object Model in InfoPath 2003 has been changed since InfoPath 2007 has been released. The new Object Model is completely managed and is integrated with the .NET Framework 2.0 classes (System.Xml namespace)
Suppose we have a ASP .NET Web Service on server which defines the following web method:
public string SayHello(string name)
return "Hello " + name;
- Now, Open your InfoPath Form Template and add a button on the screen
(Design Tasks > Controls > Button)
- Open the Button's properties by double-clicking on the button
- Click on the 'Edit Form Code...' button to start up the Visual Studio Tools for Applications.
(you can choose the programming language through the Form Options item in the Tools menu)
- Add the following lines of code to your button handler:
//do not forget to import the System.Xml namespace at the top of this class
//Create Xpath Navigator for WebService Data Source
//"SayHello" = the name of the data connection
XPathNavigator nav = this.DataSources["SayHello"].CreateNavigator();
//Xpath expression to retrieve parameter xml node
// tns:SayHello = method
// tns:name = name of the argument at server side
XPathNavigator webServiceNavi = nav.SelectSingleNode("dfs:myFields/dfs:queryFields/tns:SayHello/tns:name", this.NamespaceManager);
//retrieve data: call the "SayHello" webservice
DataConnection conn = this.DataConnections["SayHello"];
- The web method returns a string. You can drag and drop the dataFields section of your secondary data source (which corresponds to your web service connection) to the screen.
- Using managed code in Browser Enabled Forms needs an administrator approval
- In browser enabled forms you will mainly use web services to retrieve data
- Have a special attention for the security issues
- use Data Connection Files in Data Connection Libraries (UDCX)
- InfoPath Forms Services makes the big picture more difficult, it introduces a extra tier.
With InfoPath 2003, you never had to worry about security issues. You ran InfoPath on tier 1, and the Web service on tier 2. Now that you are designing forms that run in a web browser, you'll need to think about tier 3.
- Did you know that you can use your 'Receiving Data Connections' to send data? The parameters specified at server side can be used to return a filtered set of data or as input for the database ...
- Did you know that you can use your own .NET classes or Data Sets as parameter or as return value in web methods? Both are serializable to xml.
Monday, January 22, 2007
Developing InfoPath Add-In
With VSTO 2005 (Visual Studio Tools for Office) you can easily create InfoPath add-ins!
private void ThisAddIn_Startup(object sender, System.EventArgs e)
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
private TaskPaneUC tpuc;
private void CreateCustomPane()
this.tpuc = new TaskPaneUC();
this.tpuc.submitEvent += new TaskPaneUC.OnSubmit(tpuc_submitEvent);
this.tpuc.switchViewEvent += new TaskPaneUC.OnSwitchView(tpuc_switchViewEvent);
this.tpuc.exitEvent += new TaskPaneUC.OnExit(tpuc_exitEvent);
this.ctp = this.CustomTaskPanes.Add(tpuc, "Happy 2007");
this.ctp.Visible = true;
public delegate void OnSubmit(object sender, SubmitArgs args);
public event OnSubmit submitEvent;
private void CreateCustomPane()
this.tpuc.submitEvent += new TaskPaneUC.OnSubmit(tpuc_submitEvent);
Through the User control in this example you can do the following tasks
- Set a field’s value
- Switch View
- Exit application
Download this example here.
Installing the InfoPath Add-In
The add-in will be automatically installed when debugging the application.
For deployment you can use the Setup project which will be added automatically to your project.
Uninstalling the InfoPath Add-In
When you move the InfoPath Add-In project to another location, the Add-in will be automatically deactivated.
Overview of InfoPath Add-In
Friday, January 19, 2007
A. Steps at client-side (for InfoPath developers)
- Create an InfoPath form and use managed code (C#) as business logic.The business logic needs full trust on the server to run.
- Save your form and publish it to a SharePoint Server with or without InfoPath Forms Services
- If you opt for ‘Document Library’ a library will be created or updated and the template can only be used in this library. If you opt for ‘Site Content Type’, you can use your template in multiple document libraries on several sites. A site content type is nothing more than a type of document with some specific properties.
In this situation you cannot opt to create a document library or a content type because you used managed code. You must select ‘Administrator-approved form template (advanced)’. We need the ‘full trust’ security level to run .NET code.
- We can’t publish the form directly on the Sharepoint Server. First of all we must store the InfoPath form to a location which is accessible for the administrator.
B. Steps at server-side (for administrator)
- Go to Central Administrator > Application Management. Select ‘Manage Form Templates’ in the ‘InfoPath Forms Services’ section.
- Click on ‘Upload Form template’. The admin must browse to the location where the InfoPath form was stored by the developer.
- Open the context menu of the uploaded file in the Form Templates List. Select ‘Activate to a Site collection’. This will publish the InfoPath Form as a Site Content Type to a site collection.
C. Steps at server-side (for site owners)
- Go to the site collection on which you activated the InfoPath form template. Open the list where you want to install the form template.Click on Settings and select ‘Site Settings’. Click on ‘Advanced Settings’ in the ‘General Settings’ section and activate the content type management. (select ‘Yes’)
- Now you will be able to manage the Content Types. Click on ‘Add from existing site content types’ to add the activated Form Template as Site Content in this list.
- Go back to your list and Click on the ‘New’ Button to start a document based the uploaded Form Template.
Wednesday, January 10, 2007
Microsoft InfoPath 2007 offers now Custom Controls:
1. ActiveX controls (uses COM and ActiveX technologies)
2. Template Parts (reusable form pieces)
--> You can embed audio and video if you use an ActiveX custom control.
Using ActiveX Custom Controls
1. Go to menu View
2. Click on Design Tasks
3. Select Controls in the 'Design Tasks' Task pane
4. Click on the 'add or remove custom controls' button to install your custom
5. Click on the Add button and select ActiveX Control
6. Select the Windows Media Player control
7. Select the necessary properties for databinding and finish the wizard.
After you have added the control, you can drag and drop the control on your screen.
Right-Click on the control and select the 'Windows Media Player properties'
Fill in the URL to automatically embed the file to play.
ActiveX controls must be installed on each user's computer,
but you can opt to include a .cab file (which contains the custom activeX control)
in your template which automatically installs and registers your control.
(you can specify the .cab file in the 'steps' wizard above.
Posted by Kristof De Causemaeker at 11:10 pm
InfoPath cannot start Microsoft Visual Studio Tools for Applications.To work with Visual Basic or C# code, Microsoft Visual Studio Tools for Applications (VSTA) is required. the Microsoft .NET Framework 2.0 and Microsoft Core XML Services 6.0 must be installed prior to installing VSTA. To install VSTA, open Add or Remove Programs, locate your 2007 Microsoft Office System installation, and then click Change [full problem description on Jeroen Ceuppens ' blog]
The problem has a very simple solution, just respect the way you install the Office products.
SOLUTION: Please respect the following installation order ...
1. Install the Microsoft Office 2007 clients
without .NET programmability support for .NET Framework version 2.0
2. Install the .NET 3.0 framework
3. Install the Microsoft Office Sharepoint Portal Server 2007
4. Go to 'Add or Remove Programs...' and add the '.NET programmability support for .NET Framework version 2.0' right now. The installation makes sure that it has to use the .NET 2.0 framework which is already installed on the computer.
The ultimate test...
5. Start up Microsoft Office InfoPath 2007.
6. Save your blank template on your disk
7. Go to menu Tools > Programming > Microsoft Visual Studio Tools for Applications
Information about VSTA - Visual Studio Tools for Applications
You can find the VSTA executable on this location:
C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\vsta.exe
C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\vsta.exe.config
Have a look at the vsta.exe.config file. You will see that vsta.exe requires the v.2.0.
<supportedruntime version="v2.0.50727" safemode="true"/>
<requiredruntime version="v2.0.50727" safemode="true"/>
A better solution would be: first install the Office 2007 server products and afterwards you can install all Office 2007 Clients on it. (I did not test this remark ...)
Tuesday, January 09, 2007
Check out following articles:
Geert Verhoeven is writing about .NET applets. Simply using .NET controls within your browser. Read the article about his first .NET applet.
Maarten Balliauw wrote an article about NHibernate, the .NET version of Hibernate.
Jeroen Ceuppens (a collegue) and I experienced some troubles when using Office InfoPath 2007 in combination with .NET 3.0.
When you try to start up VSTA within InfoPath 2007, you will receive a message which says that VSTA is not installed on your computer yet ... The computer is also complaining about MSXML 6.0... So MSXML 6.0 and VSTA must be installed on your computer ?!
Jeroen described the whole problem on his blog. Please check out and provide us some feedback if possible!