Export (0) Print
Expand All

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)

'Declaration
<GuidAttribute("543DD7B9-6E48-438d-86D8-100000000000")> _
PublicNotInheritableClassFormTemplateCollection _
	InheritsSPPersistedChildCollection(OfFormTemplate) _
	ImplementsIBackupRestoreConfiguration, IBackupRestore
'Usage
DiminstanceAsFormTemplateCollection

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\14.0\Bin.

The following import statements are required for the

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

    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

The following using statements are required for the

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

    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.

Community Additions

ADD
Show:
© 2014 Microsoft