FormTemplate.Deactivate Method
Deactivates a form template from a SharePoint site collection.
Namespace: Microsoft.Office.InfoPath.Server.Administration
Assembly: Microsoft.Office.InfoPath.Server (in Microsoft.Office.InfoPath.Server.dll)
Syntax
'Declaration
Public Sub Deactivate ( _
site As SPSite _
)
'Usage
Dim instance As FormTemplate
Dim site As SPSite
instance.Deactivate(site)
public void Deactivate(
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.
Remarks
Deactivating a form template from a site removes the form template from the Form Templates library of the root of the site collection and from the available content types of the site collection.
Examples
The following example deactivates all form templates uploaded to the server farm from the "HRDept" site collection, and writes a message to the console for each form template that is deactivated.
Visual Basic
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("https://server/sites/HRDept/")
LocalFormsService = LocalFarm.Services.GetValue(Of FormsService)(FormsService.ServiceName)
For Each ft In LocalFormsService.FormTemplates
ft.Deactivate(ExampleSite)
Console.WriteLine("Form template " & ft.Name & " deactivated from 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