SPFieldCollection.GetField Method

Returns the field with the specified internal, display, or static name from the collection.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online

Syntax

'Declaration
<ClientCallableMethodAttribute(Name := "GetByInternalNameOrTitle", CacheReturnValue := True)> _
<ClientCallableExceptionConstraintAttribute(FixedId := "a", ErrorType := GetType(ArgumentException),  _
    Condition := "The field with the specified internal name or title does not exist in the collection at the given scope.",  _
    ErrorCode := )> _
<ClientCallableExceptionConstraintAttribute(FixedId := "e", ErrorType := GetType(SPException),  _
    Condition := "There is a COM exception which is not a throttle failure or a join throttle failure.",  _
    ErrorCode := )> _
<ClientCallableExceptionConstraintAttribute(FixedId := "c", ErrorType := GetType(SPQueryThrottledException),  _
    Condition := "There is a throttle failure.", ErrorCode := )> _
<ClientCallableExceptionConstraintAttribute(FixedId := "b", ErrorType := GetType(UnauthorizedAccessException),  _
    Condition := "User does not have permissions to get the field.",  _
    ErrorCode := )> _
<ClientCallableExceptionConstraintAttribute(FixedId := "d", ErrorType := GetType(SPQueryThrottledException),  _
    Condition := "There is a join throttle failure.", ErrorCode := )> _
Public Function GetField ( _
    strName As String _
) As SPField
'Usage
Dim instance As SPFieldCollection
Dim strName As String
Dim returnValue As SPField

returnValue = instance.GetField(strName)
[ClientCallableMethodAttribute(Name = "GetByInternalNameOrTitle", CacheReturnValue = true)]
[ClientCallableExceptionConstraintAttribute(FixedId = "a", ErrorType = typeof(ArgumentException), 
    Condition = "The field with the specified internal name or title does not exist in the collection at the given scope.", 
    ErrorCode = )]
[ClientCallableExceptionConstraintAttribute(FixedId = "e", ErrorType = typeof(SPException), 
    Condition = "There is a COM exception which is not a throttle failure or a join throttle failure.", 
    ErrorCode = )]
[ClientCallableExceptionConstraintAttribute(FixedId = "c", ErrorType = typeof(SPQueryThrottledException), 
    Condition = "There is a throttle failure.", ErrorCode = )]
[ClientCallableExceptionConstraintAttribute(FixedId = "b", ErrorType = typeof(UnauthorizedAccessException), 
    Condition = "User does not have permissions to get the field.", 
    ErrorCode = )]
[ClientCallableExceptionConstraintAttribute(FixedId = "d", ErrorType = typeof(SPQueryThrottledException), 
    Condition = "There is a join throttle failure.", ErrorCode = )]
public SPField GetField(
    string strName
)

Parameters

  • strName
    Type: System.String

    A string that specifies either the internal, display, or static name of the field.

Return Value

Type: Microsoft.SharePoint.SPField
An SPField object that represents the field.

Exceptions

Exception Condition
ArgumentException

The field is not found.

Remarks

Microsoft SharePoint Foundation searches first by internal name; then, if necessary, by display name; finally, if necessary, by static name.

See Also

Reference

SPFieldCollection Class

SPFieldCollection Members

Microsoft.SharePoint Namespace