Field

Configure a SharePoint field (column).


Access

Access the Field API using the getByTitle() or getById() method of the Fields API.

Examples

up(engineer) {
// Update field in web
engineer.web.fields.getByTitle('My Field').update({
Description: 'New field description',
});

// Update field in list
engineer.web.lists.getByTitle('My List').fields.getByTitle('New Field').update({
Description: 'New field description',
});
}

Methods

kind(type)

Get the SharePoint FieldTypeKind value for the given field type. SharePoint internally refers to each field type by number. For the sake of brevity, the migration API can translate a type String into the correct FieldTypeKind value using this method. This is a static method that can be accessed using engineer.fieldKind(type).

Parameters

type
The field type; possible values are "Boolean", "Calculated", "Choice", "Currency", "DateTime", "Geolocation", "Lookup", "MultiChoice", "MultiLineText", "Number", "Text", "Url", or "User" (String, required)

Returns

Number
The SharePoint FieldTypeKind value for the given string, or 2 ("Text" type) if no type is found

Examples

up(engineer) {
// Create Text field
engineer.web.fields.add('NewTextColumn');

// Change to MultiLineText field
engineer.web.fields.getByTitle('NewTextColumn').update({
FieldTypeKind: engineer.fieldKind('MultiLineText'),
});
}

update(options)

Update the field.

Parameters

options
Updated field configuration (Object, required)

Properties of options

See Microsoft’s Field resource documentation for a listing of all possible properties that can be passed to the REST API.

Examples

up(engineer) {
// Update a field
engineer.web.fields.getByTitle('MyField').update({
DefaultValue: '0',
Description: 'A new description',
Group: 'A new group',
});

// Make field required
engineer.web.fields.getByTitle('MyField').update({
Required: true,
});
}

delete()

Delete the field.

Examples

down(engineer) {
// Delete field from web
engineer.web.fields.getByTitle('MyField').delete();

// Delete field from list
engineer.web.lists.getByTitle('My List').fields.getByTitle('MyField').delete();
}