Skip to main content

spo list view add

Adds a new view to a SharePoint list

Usage

m365 spo list view add [options]

Options

-u, --webUrl <webUrl>

URL of the site where the list is located.

--listId [listId]

ID of the list to which the view should be added. Specify either listId, listTitle, or listUrl but not multiple.

--listTitle [listTitle]

Title of the list to which the view should be added. Specify either listId, listTitle, or listUrl but not multiple.

--listUrl [listUrl]

Relative URL of the list to which the view should be added. Specify either listId, listTitle, or listUrl but not multiple.

--title <title>

Title of the view to be created for the list.

--fields <fields>

Comma-separated list of case-sensitive internal names of the fields to add to the view.

--viewQuery [viewQuery]

XML representation of the list query for the underlying view.

--personal

View will be created as personal view, if specified.

--default

View will be set as default view, if specified.

--paged

View supports paging, if specified (recommended to use this).

--rowLimit [rowLimit]

Sets the number of items to display for the view. Default value is 30.

-h, --help [help]

Output usage information. Optionally, specify which section of command's help you want to see. Allowed values are options, examples, remarks, response, full. Default is options.

--query [query]

JMESPath query string. See http://jmespath.org/ for more information and examples.

-o, --output [output]

Output type. json, text, csv, md, none. Default json.

--verbose

Runs command with verbose logging.

--debug

Runs command with debug logging.

Remarks

We recommend using the paged option. When specified, the view supports displaying more items page by page (default behavior). When not specified, the rowLimit is absolute, and there is no link to see more items.

Examples

Add a view called All events to a list with specific title.

m365 spo list view add --webUrl https://contoso.sharepoint.com/sites/project-x --listTitle "Test" --title "All events" --fields "FieldName1,FieldName2,Created,Author,Modified,Editor" --paged

Add a view as default view with title All events to a list with a specific URL.

m365 spo list view add --webUrl https://contoso.sharepoint.com/sites/project-x --listUrl "/Lists/MyList" --title "All events" --fields "FieldName1,Created" --paged --default

Add a personal view called All events to a list with a specific ID.

m365 spo list view add --webUrl https://contoso.sharepoint.com/sites/project-x --listId 00000000-0000-0000-0000-000000000000 --title "All events" --fields "FieldName1,Created" --paged --personal

Add a view called All events with defined filter and sorting.

m365 spo list view add --webUrl https://contoso.sharepoint.com/sites/project-x --listTitle "Test" --title "All events" --fields "FieldName1" --viewQuery "<OrderBy><FieldRef Name='Created' Ascending='FALSE' /></OrderBy><Where><Eq><FieldRef Name='TextFieldName' /><Value Type='Text'>Field value</Value></Eq></Where>" --paged

Response

{
"Aggregations": null,
"AggregationsStatus": null,
"AssociatedContentTypeId": null,
"BaseViewId": null,
"CalendarViewStyles": null,
"ColumnWidth": null,
"ContentTypeId": {
"StringValue": "0x"
},
"CustomFormatter": null,
"CustomOrder": null,
"DefaultView": false,
"DefaultViewForContentType": false,
"EditorModified": false,
"Formats": null,
"GridLayout": null,
"Hidden": false,
"HtmlSchemaXml": "<View Type=\"HTML\" Url=\"/Lists/Test/All events.aspx\" Personal=\"FALSE\" DisplayName=\"All events\" DefaultView=\"FALSE\" Name=\"{3CD2E934-F482-4D4A-A9B8-A13B49B3D226}\"><ViewFields><FieldRef Name=\"Title\" /></ViewFields><Query><OrderBy><FieldRef Name=\"Created\" Ascending=\"FALSE\" /></OrderBy><Where><Eq><FieldRef Name=\"TextFieldName\" /><Value Type=\"Text\">Field value</Value></Eq></Where></Query><RowLimit Paged=\"TRUE\">30</RowLimit></View>",
"Id": "3cd2e934-f482-4d4a-a9b8-a13b49b3d226",
"ImageUrl": null,
"IncludeRootFolder": false,
"ViewJoins": null,
"JSLink": null,
"ListViewXml": "<View Type=\"HTML\" Url=\"/Lists/Test/All events.aspx\" Personal=\"FALSE\" DisplayName=\"All events\" DefaultView=\"FALSE\" Name=\"{3CD2E934-F482-4D4A-A9B8-A13B49B3D226}\" ><Query><OrderBy><FieldRef Name=\"Created\" Ascending=\"FALSE\" /></OrderBy><Where><Eq><FieldRef Name=\"TextFieldName\" /><Value Type=\"Text\">Field value</Value></Eq></Where></Query><ViewFields><FieldRef Name=\"Title\" /></ViewFields><RowLimit Paged=\"TRUE\">30</RowLimit><Toolbar Type=\"None\"/></View>",
"Method": null,
"MobileDefaultView": false,
"MobileView": false,
"ModerationType": null,
"NewDocumentTemplates": null,
"OrderedView": false,
"Paged": true,
"PersonalView": false,
"ViewProjectedFields": null,
"ViewQuery": "<OrderBy><FieldRef Name=\"Created\" Ascending=\"FALSE\" /></OrderBy><Where><Eq><FieldRef Name=\"TextFieldName\" /><Value Type=\"Text\">Field value</Value></Eq></Where>",
"ReadOnlyView": false,
"RequiresClientIntegration": false,
"RowLimit": 30,
"Scope": 0,
"ServerRelativePath": {
"DecodedUrl": "/Lists/Test/All events.aspx"
},
"ServerRelativeUrl": "/Lists/Test/All events.aspx",
"StyleId": null,
"TabularView": true,
"Threaded": false,
"Title": "All events",
"Toolbar": null,
"ToolbarTemplateName": null,
"ViewType": "HTML",
"ViewData": null,
"ViewType2": null,
"VisualizationInfo": null
}
CTRL + M