FieldLinks

Configure SharePoint fields (columns) in a content type.


Access

Access the FieldLinks API using the fieldLinks property of the ContentType API.

Examples

up(engineer) {
// Add field to web content type
engineer.web.contentTypes.getByName('My Content Type').fieldLinks.add('My Field');

// Add field to list content type
engineer.web.lists.getByTitle('My List').contentTypes.getByName('My Content Type').fieldLinks.add('My Field');
}

Methods

add(name)

Add an existing field to the content type. This method uses the SharePoint client-side object model (CSOM).

Parameters

name
The name of the existing field or column to be added to the content type; this field must already be available on the parent Web or List (String, required)

Examples

up(engineer) {
// Create fields
engineer.web.fields.add('Breed');
engineer.web.fields.add('Weight');

// Create content type
engineer.web.contentTypes.add('Pet');

// Add fields to content type
engineer.web.contentTypes.getByName('Pet').fieldLinks.add('Breed');
engineer.web.contentTypes.getByName('Pet').fieldLinks.add('Weight');
}

remove(name)

Remove a field from the content type. This method uses the SharePoint client-side object model (CSOM).

Parameters

name
The name of the field or column to be removed from the content type (String, required)

Examples

down(engineer) {
// Remove fields from content type
engineer.web.contentTypes.getByName('Pet').fieldLinks.remove('Breed');
engineer.web.contentTypes.getByName('Pet').fieldLinks.remove('Weight');
}