Export (0) Print
Expand All

SPField.Update Method

Updates the database with changes that are made to the field.

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

[ClientCallableExceptionConstraintAttribute(FixedId = "FieldCalculatedFormula3", ErrorCode = , 
	Condition = "The formula for a FieldCalculated contains a circular reference", 
	ErrorType = typeof(SPException))]
[ClientCallableExceptionConstraintAttribute(FixedId = "FieldCalculatedFormula7", ErrorCode = , 
	Condition = "The formula for a FieldCalculated refers functions or semi-calculated formula", 
	ErrorType = typeof(SPException))]
[ClientCallableExceptionConstraintAttribute(FixedId = "FieldCalculatedFormula4", ErrorCode = , 
	Condition = "The formula for a FieldCalculated refers to a field whose FieldTypeKind is not allowed in formula", 
	ErrorType = typeof(SPException))]
[ClientCallableExceptionConstraintAttribute(FixedId = "1", ErrorCode = , Condition = "Trying to set UCC property to true for a field which is not indexed", 
	ErrorType = typeof(SPException))]
[ClientCallableExceptionConstraintAttribute(FixedId = "2", ErrorCode = , Condition = "Tying to un-index a field which does not allow duplicate values.", 
	ErrorType = typeof(SPException))]
[ClientCallableExceptionConstraintAttribute(FixedId = "3", ErrorCode = , Condition = "Trying to change the type of a field which does not allow duplicate values.", 
	ErrorType = typeof(SPException))]
[ClientCallableExceptionConstraintAttribute(FixedId = "4", ErrorCode = , Condition = "Trying to change the type of a field to bool where allowing duplicate values in the field is not supported.", 
	ErrorType = typeof(SPException))]
[ClientCallableExceptionConstraintAttribute(FixedId = "5", ErrorCode = , Condition = "Trying to index and set UCC property to true to a field and the field has duplicate values in the existing list items.", 
	ErrorType = typeof(SPException))]
[ClientCallableExceptionConstraintAttribute(FixedId = "6", ErrorCode = , Condition = "Trying to change the type of a field which is also changing to be indexed or which is already indexed.", 
	ErrorType = typeof(SPException))]
[ClientCallableExceptionConstraintAttribute(FixedId = "7", ErrorCode = , Condition = "Trying to set UCC to true to a lookup field which is also changing to be indexed or which is already indexed.", 
	ErrorType = typeof(SPException))]
[ClientCallableExceptionConstraintAttribute(FixedId = "FieldCalculatedFormula2", ErrorCode = , 
	Condition = "The formula for a FieldCalculated has a syntax error", 
	ErrorType = typeof(SPException))]
[ClientCallableExceptionConstraintAttribute(FixedId = "Update2", ErrorCode = , Condition = "Field does not exist", 
	ErrorType = typeof(SPException))]
[ClientCallableExceptionConstraintAttribute(FixedId = "Update5", ErrorCode = , Condition = "Total Number of fields in the list exceeds the limit", 
	ErrorType = typeof(SPException))]
[ClientCallableAttribute]
[ClientCallableExceptionConstraintAttribute(FixedId = "FieldType1", ErrorCode = , Condition = "If the field is derived from a built-in field type or the field is referred by another Calculated Field and is not changing to either FieldType.Text, FieldType.Calculated, FieldType.Number, FieldType.Integer, FieldType.Currency, FieldType.DateTime, FieldType.Coice, or FieldType.Boolean or the field type change is not allowed", 
	ErrorType = typeof(SPException))]
[ClientCallableExceptionConstraintAttribute(FixedId = "accessdenied", Condition = "User does not have permissions to update this list.", 
	ErrorType = typeof(UnauthorizedAccessException))]
[ClientCallableExceptionConstraintAttribute(FixedId = "FieldCalculatedFormula5", ErrorCode = , 
	Condition = "The formula for a FieldCalculated refers to a field that does not exist", 
	ErrorType = typeof(SPException))]
[ClientCallableExceptionConstraintAttribute(FixedId = "Update3", ErrorCode = , Condition = "Trying to change UCC from false to true or trying to index the field and the current user does not have permission to do big list operation", 
	ErrorType = typeof(SPQueryThrottledException))]
public virtual void Update()

ExceptionCondition
SPException

An error was encountered during the operation.

The following code example updates the display name, default value, and description for the specified field.

SPSite oSiteCollection = SPContext.Current.Site;
SPList oList = 
    oSiteCollection.AllWebs["Site_Name"].Lists["List_Name"];
SPField oField = oList.Fields["Field_Name"];

oField.DefaultValue = "Default_Value";
oField.Description = "Description";
oField.Title = "New_Field_Title";

oField.Update();

Community Additions

ADD
Show:
© 2014 Microsoft