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

FormTemplate.Activate method

Activates a form template to a SharePoint site collection.

Namespace:  Microsoft.Office.InfoPath.Server.Administration
Assembly:  Microsoft.Office.InfoPath.Server (in Microsoft.Office.InfoPath.Server.dll)
public void Activate(
	SPSite site
)

Parameters

site
Type: Microsoft.SharePoint.SPSite

A SPSite object representing the site to which the form template is activated. Can be either the root site of the site collection or a subsite within the collection.

An administrator approved form template is not available for use on a SharePoint site until it is activated to the site. Using the Activate method for a form template will make the form template available in the Form Templates library of the root site in the site collection, and as a content type available for subsites of the site collection. The equivalent procedure on the Central Administration site is Activate to a Site Collection, available on the drop-down menu of a form template on the Manage form templates page.

The following example activates all form templates uploaded to the server farm to a site collection, and writes a message to the console for each form template that is activated.

An additional imports statement is required for the Microsoft.SharePoint namespace.

    Dim LocalFormsService As FormsService
    Dim LocalFarm As SPFarm
    Dim ft As FormTemplate
    Dim ExampleSite As SPSite

    Try
        LocalFarm = SPFarm.Local
        ExampleSite = New SPSite("http://server/sites/hrteam/")
        LocalFormsService = LocalFarm.Services.GetValue(Of FormsService)(FormsService.ServiceName)
        For Each ft In LocalFormsService.FormTemplates
            ft.Activate(ExampleSite)
            Console.WriteLine("Form template " & ft.Name & " activated to the " & ExampleSite.ToString())
        Next

        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
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.