Views

Configure SharePoint views in a list.


Access

Access the Views API using the views property of List.

Examples

up(engineer) {
// Add a view
engineer.web.lists.getByTitle('My List').views.add('My View');
}

Methods

getById(id)

Get a view by its ID or GUID. We highly recommend using the getByTitle method for any custom views created by Engineer, as the view ID may change from environment to environment.

Parameters

id
The ID or GUID of the view to be retrieved (String, required)

Returns

View

Examples

up(engineer) {
// Update view by ID
engineer.web.lists.getByTitle('My List').views.getById('5beb5527-6646-4f12-be01-ed7a5dca3488').update({
RowLimit: 100,
});
}

getByTitle(title)

Get a view by its title.

Parameters

title
The title of the view (String, required)

Returns

View

Examples

up(engineer) {
// Update view by title
engineer.web.lists.getByTitle('My List').views.getByTitle('My View').update({
RowLimit: 100,
});
}

add(options|title)

Add a new view to the target List.

Parameters

options
New view configuration (Object, required)
title
If a String is provided instead of options, a new view with this title will be created with default configuration (String, override)

Properties of options

Title
A title for the new view (String, required)
PersonalView
Specifies whether this is a personal view (default: false) (Boolean, optional)
*
See Microsoft’s View resource documentation for a listing of all possible properties that can be passed to the REST API

Examples

up(engineer) {
// Add simple view to list
engineer.web.lists.getByTitle('My List').views.add('My Simple View');

// Add view with options to list
engineer.web.lists.getByTitle('My List').views.add({
Title: 'My View',
RowLimit: 100,
});
}