Tuesday, January 30, 2007

7 Development Projects for Sharepoint 2007 and Sharepoint Services 3.0

Thanks to Geert I found this interesting e-book about Sharepoint 2007

It's a free book about 7 Development Projects for Microsoft Office Sharepoint Server 2007 and Windows Sharepoint Services 3.0

You can download it

Querying Data Connections using the InfoPath 2007 Object model

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
    using System.Xml;

    //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);

    //set parameter(s)

    //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

Creating Custom Taskpanes with .NET User Controls in VSTO

Developing InfoPath Add-In

With VSTO 2005 (Visual Studio Tools for Office) you can easily create InfoPath add-ins!
Watch ...

  • First download VSTO on the Microsoft website (free download)
  • After installation, start up Visual Studio 2005 and select the InfoPath2007 add-in as template.
  • In your project contains 2 methods:
    private void ThisAddIn_Startup(object sender, System.EventArgs e)
    private void ThisAddIn_Shutdown(object sender, System.EventArgs e)

  • Since InfoPath 2007 we can use .NET User Controls as Custom Task Pane. In InfoPath 2003 we had to use JavaScript, ASP.NET or HTML files. We can also use help files (CHM files) as custom task pane.
  • Add a new Item to your project (User Control)You can add Windows controls to this User Control.

  • To show the Custom TaskPane we have to add some code to the ThisAddIn_Startup method.In the Startup method you call the CreateCustomPane() method below:

    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;
  • For redirecting button actions to the ThisAddIn.cs we use delegates and events.

    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

    1. Open InfoPath 2007.
    2. Go to the Help menu and select 'Privacy Options'

    Friday, January 19, 2007

    Walkthrough: Publishing administrator-approved form templates

    A. Steps at client-side (for InfoPath developers)

    1. Create an InfoPath form and use managed code (C#) as business logic.The business logic needs full trust on the server to run.

    2. Save your form and publish it to a SharePoint Server with or without InfoPath Forms Services

    3. 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.

    4. 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)

    1. Go to Central Administrator > Application Management. Select ‘Manage Form Templates’ in the ‘InfoPath Forms Services’ section.

    2. Click on ‘Upload Form template’. The admin must browse to the location where the InfoPath form was stored by the developer.

    3. 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)

    1. 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’)

    2. 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.

    3. Go back to your list and Click on the ‘New’ Button to start a document based the uploaded Form Template.

    Wednesday, January 10, 2007

    Embedding audio and video in InfoPath 2007 forms

    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.

    Attention ...
    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.


    Reference: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1039675&SiteID=1

    VSTA/VSTO problem when installing Office InfoPath 2007 & .NET 3.0 *solved*

    Error message:
    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

    Articles: Using .NET applets in browsers & NHibernate explained

    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.

    VSTA/VSTO problem when installing Office InfoPath 2007 & .NET 3.0 ...

    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!