Partilhar via


FormTemplateCollection.Item Method (Guid)

Gets a reference to a form template in the FormTemplateCollection collection using a GUID.

Namespace:  Microsoft.Office.InfoPath.Server.Administration
Assembly:  Microsoft.Office.InfoPath.Server (in Microsoft.Office.InfoPath.Server.dll)

Syntax

'Declaration
Public Function Item ( _
    templateId As Guid _
) As FormTemplate
'Usage
Dim instance As FormTemplateCollection
Dim templateId As Guid
Dim returnValue As FormTemplate

returnValue = instance.Item(templateId)
public FormTemplate Item(
    Guid templateId
)

Parameters

  • templateId
    Type: System.Guid
    The Globally Unique Identifier (GUID) of the form template.

Return Value

Type: Microsoft.Office.InfoPath.Server.Administration.FormTemplate
A FormTemplate object.

Remarks

You can find the GUID of a form template by selecting its properties from the drop-down available on the Manage form templates page of the Central Administration site, or by using a procedure similar to the code example.

Examples

In the following examples, a known GUID is used to get a reference to a form template on the server farm, and its status is written to the console:

    Dim LocalFormsService As FormsService
    Dim LocalFarm As SPFarm
    Dim MyFt As FormTemplate
    Dim FtGuid As Guid
    Dim MyGuid As String
    MyGuid = "{371a56c4-348a-4d7d-bd32-cdd416206d57}"
    FtGuid = New Guid(MyGuid)
    Try
        LocalFarm = SPFarm.Local
        LocalFormsService = LocalFarm.Services.GetValue(Of FormsService)(FormsService.ServiceName)
        MyFt = LocalFormsService.FormTemplates.Item(FtGuid))
        Console.WriteLine("Form Template Status: " + MyFt.Status.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 
    FormsService localFormsService;
    SPFarm localFarm = SPFarm.Local;
    Guid ftGuid;
    String myGuid;
    FormTemplate myFt;
    myGuid = "{371a56c4-348a-4d7d-bd32-cdd416206d57}";
    ftGuid = new Guid(myGuid);
    try
    {
        localFormsService = localFarm.Services.GetValue<FormsService>(FormsService.ServiceName);
        myFt = localFormsService.FormTemplates.Item(ftGuid);
        Console.WriteLine("Form Template Status: " + myFt.Status.ToString());
        Console.Write("Press Enter to Continue");
        Console.ReadLine();
    }
    catch (Exception ex)
    {
        Console.WriteLine("Error: " + ex.Message);
        Console.Write("\nPress Enter to Continue");
        Console.ReadLine();
    }

See Also

Reference

FormTemplateCollection Class

FormTemplateCollection Members

Item Overload

Microsoft.Office.InfoPath.Server.Administration Namespace