MetadataDefaults.GetFieldDefault method (SPFolder, String)

Gets the default value for a specified folder and field.

Namespace:  Microsoft.Office.DocumentManagement
Assembly:  Microsoft.Office.DocumentManagement (in Microsoft.Office.DocumentManagement.dll)

Syntax

'Declaration
Public Function GetFieldDefault ( _
    folder As SPFolder, _
    fieldName As String _
) As String
'Usage
Dim instance As MetadataDefaults
Dim folder As SPFolder
Dim fieldName As String
Dim returnValue As String

returnValue = instance.GetFieldDefault(folder, _
    fieldName)
public string GetFieldDefault(
    SPFolder folder,
    string fieldName
)

Parameters

  • fieldName
    Type: System.String

    The internal name of the SPField object for the field to get the default for

Return value

Type: System.String
The default value set on the field indicated by the fieldName parameter at the folder location, or String.Empty if no metadata default is defined for the current SPFolder object.

Exceptions

Exception Condition
ArgumentNullException

The folder parameter is set to a null reference (Nothing in Visual Basic). The folder parameter should be a non-null SPFolder object that represents a folder in the document library. (ArgumentNullException.ParamName="folder")

ArgumentNullException

The fieldName parameter is set to a null reference (Nothing in Visual Basic) or set to String.Empty. The fieldName parameter should be the internal name of a field on the document library.(ArgumentNullException.ParamName="fieldName")

Examples

SPSite site = new SPSite("http://contoso"); SPWeb web = new site.OpenWeb("/"); MetadataDefaults defaults = MetadataDefaults("/Documents", web); SPFolder folder = web.GetFolder("/Documents/AdventureWorks"); string defaultValue = defaults.GetFieldDefault(folder, "Title");

See also

Reference

MetadataDefaults class

MetadataDefaults members

GetFieldDefault overload

Microsoft.Office.DocumentManagement namespace

MetadataDefaults