SP.FieldLinkCollection.add Method (sp.js)

Adds a content type field reference to the collection.

Applies to: apps for SharePoint | SharePoint Foundation 2013 | SharePoint Server 2013

SP.FieldLinkCollection.add()

Parameters

  • parameters
    Type: SP.FieldLinkCreationInformation

    A SP.FieldLinkCreationInformation object that contains information about the field reference.

    It must not be null.

Return value

Type: SP.FieldLink

REST resource endpoint

In some ways, the REST endpoint is not parallel to the JavaScript function, as noted below.

Endpoint URI structure

http://<sitecollection>/<site>/_api/web/lists(listid)/contenttypes(contenttypeid)/fieldlinks

HTTP requests

This resource supports the following HTTP commands:

  • POST

POST syntax

POST http://<sitecollection>/<site>/_api/web/lists(listid)/contenttypes(contenttypeid)/fieldlinks

Note

There is no "add" on the REST URL.

The body should contain an SP.FieldLink object, not a SP.FieldLinkCreationInformation object. For example:

{ '__metadata': { 'type': 'SP.FieldLink' }, 'FieldInternalName': 'MyField', 'Hidden': false, 'Required':true}

Note the following restrictions on adding a field (column) to a content type using the REST service:

  • Site Columns cannot be added to a content type using the REST service.

  • You can add a field to a site content type only if the field already exists on the parent content type.

  • You can add a field to a content type associated with a list only if the field already exists on the list. To add a completely new field to a list content type, you have to first add it to the list and then add it to the content type in a separate call to the REST service.

Resource parameters

  • parameters