Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

FormTemplateCollection Class

Represents all Administrator-approved form templates on the server farm.

Namespace:  Microsoft.Office.InfoPath.Server.Administration
Assembly:  Microsoft.Office.InfoPath.Server (in Microsoft.Office.InfoPath.Server.dll)
[GuidAttribute("543DD7B9-6E48-438d-86D8-100000000000")]
public sealed class FormTemplateCollection : SPPersistedChildCollection<FormTemplate>

User form templates and those deployed as content types to site collections are not enumerated in the FormTemplateCollection collection. Administrator-approved form templates are deployed as content types, and are enumerated in the collection.

The following two examples write the count of Administrator-approved form templates to the console. References are required in the Visual Studio project to the [Microsoft.Office.Server], [Microsoft.Office.InfoPath.Server], and [Microsoft.SharePoint] assemblies.

NoteNote

Browse for the [Microsoft.Office.InfoPath.Server] assembly at <drive>:\Program Files\Microsoft Office Servers\12.0\Bin.

Visual Basic

The following import statements are required for the

[Microsoft.Office.Server], [Microsoft.Office.InfoPath.Server.Administration], and [Microsoft.SharePoint.Administration] namespaces:

Visual Basic

    Dim LocalFormsService As FormsService
    Dim LocalFarm As SPFarm
    Dim FormTemps As Integer

    Try
        LocalFarm = SPFarm.Local
        LocalFormsService = LocalFarm.Services.GetValue(Of FormsService)(FormsService.ServiceName)
        FormTemps = LocalFormsService.FormTemplates.Count()
        Console.WriteLine("Number of form templates: " & FormTemps.ToString())
        Console.Write("Press Enter to Continue")
        Console.ReadLine()
    Catch ex As Exception
        Console.WriteLine("Error: " + ex.Message)
        Console.Write("Press Enter to Continue")
        Console.ReadLine()
    End Try

C#

The following using statements are required for the

[Microsoft.Office.Server], [Microsoft.Office.InfoPath.Server.Administration], and [Microsoft.SharePoint.Administration] namespaces.

C#

    FormsService localFormsService;
    SPFarm localFarm = SPFarm.Local;
    Int16 formTemps;

    try
    {
        localFormsService = localFarm.Services.GetValue<FormsService>(FormsService.ServiceName);
        formTemps = (Int16)localFormsService.FormTemplates.Count;
        Console.WriteLine("Number of form templates: " + formTemps.ToString());
        Console.Write("Press Enter to Continue");
        Console.ReadLine();
    }
    catch (Exception ex)
    {
        Console.WriteLine("Error: " + ex.Message);
        Console.Write("Press Enter to Continue");
        Console.ReadLine();
    }
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.