SP.Field object
Represents a field in a list on a Microsoft SharePoint Foundation Web site.
Last modified: January 06, 2016
Applies to: apps for SharePoint | SharePoint Foundation 2013 | SharePoint Server 2013
var object = new SP.Field()
The Field object has the following members.
Constructor
The Field object has the following constructor.
Methods
The Field object has the following methods.
|
Method |
Description |
|---|---|
|
Deletes the field from the list, from the site, or from the content types within the list. |
|
|
Sets the value of the ShowInDisplayForm property for this field. |
|
|
Sets the value of the ShowInEditForm property for this field. |
|
|
Sets the value of the ShowInNewForm property for this field. |
|
|
Commits changed properties of the field. |
|
|
Commits changed properties of the field and optionally propagates changes to all lists that use the field. |
|
|
Validates and parses the input value and updates the value of the list item. |
Properties
The Field object has the following properties.
|
Property |
Description |
||
|---|---|---|---|
|
Gets a value that specifies whether the field can be deleted. |
|||
|
Gets or sets a value that specifies the default value for the field. |
|||
|
Gets or sets a value that specifies the description of the field. |
|||
|
Gets or sets a value that specifies the reading order of the field. |
|||
|
Gets or sets a value that specifies whether to require unique field values in a list or library column. |
|||
|
Gets the name of the entity property for the list item entity that uses this field. |
|||
|
Gets or sets a value that specifies the type of the field. |
|||
|
Gets a value that specifies whether list items in the list can be filtered by the field value. |
|||
|
Gets a Boolean value that indicates whether the field derives from a base field type. |
|||
|
Gets or sets a value that specifies the field group. |
|||
|
Gets or sets a value that specifies whether the field is hidden in list views and list forms. |
|||
|
Gets a value that specifies the field identifier. |
|||
|
Gets or sets a Boolean value that specifies whether the field is indexed. |
|||
|
Gets a value that specifies the field internal name. |
|||
|
Gets or sets the name of an external JS file containing any client rendering logic for fields of this type.
|
|||
|
Gets or sets a value that specifies whether the value of the field is read-only. |
|||
|
Gets or sets a value that specifies whether the field requires a value. |
|||
|
Gets or sets a value that specifies the XML schema that defines the field. |
|||
|
Gets the schema that defines the field and includes resource tokens. |
|||
|
Gets a value that specifies the server-relative URL of the list or the site to which the field belongs. |
|||
|
Gets a value that specifies whether properties on the field cannot be changed and whether the field cannot be deleted. |
|||
|
Gets a value that specifies whether list items in the list can be sorted by the field value. |
|||
|
Gets or sets a value that specifies a customizable identifier of the field. |
|||
|
Gets or sets value that specifies the display name of the field. |
|||
|
Gets or sets a value that specifies the type of the field. |
|||
|
Gets a value that specifies the display name for the type of the field. |
|||
|
Gets a value that specifies the description for the type of the field. |
|||
|
Gets or sets a value that specifies the data validation criteria for the value of the field. |
|||
|
Gets or sets a value that specifies the error message returned when data validation fails for the field. |
The following example creates an input button on an application page that gets a specified field, creates a description for the field, and displays the field title and new description.
<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server"> <script type="text/ecmascript" language="ecmascript"> var fieldCollection; var oneField = null; function runCode() { var clientContext = SP.ClientContext.get_current(); if (clientContext != undefined && clientContext != null) { var webSite = clientContext.get_web(); taskList = webSite.get_lists().getByTitle("Tasks"); fieldCollection = taskList.get_fields(); this.oneField = fieldCollection.getByInternalNameOrTitle("Title"); this.oneField.set_description("MyNewFieldDescription"); this.oneField.update(); clientContext.load(this.fieldCollection); clientContext.load(this.oneField); clientContext.executeQueryAsync(Function.createDelegate(this, this.OnLoadSuccess), Function.createDelegate(this, this.OnLoadFailed)); } } function OnLoadSuccess(sender, args) { var fieldInfo = ''; fieldInfo += 'Field Title: ' + oneField.get_title() + '\n' + 'Description: ' + oneField.get_description() + '\n'; alert(fieldInfo); } function OnLoadFailed(sender, args) { alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace()); } </script> <input id="Button1" type="button" value="Run Code" onclick="runCode()" /> </asp:Content>
See Field resource for more information.
Endpoint URI structure
http://<sitecollection>/<site>/_api/web/lists(listid)/fields(fieldid)
HTTP requests
This resource supports the following HTTP commands:
DELETE syntax
DELETE http://<sitecollection>/<site>/_api/web/lists(listid)/fields(fieldid)
MERGE syntax
MERGE http://<sitecollection>/<site>/_api/web/lists(listid)/fields(fieldid)
POST syntax
POST http://<sitecollection>/<site>/_api/web/lists(listid)/fields(fieldid)
PUT syntax
PUT http://<sitecollection>/<site>/_api/web/lists(listid)/fields(fieldid)
Note