Skip to content

Commit d3d6c46

Browse files
committed
Enhances 'spo list view add' with extra types. Closes #6735
1 parent 9d7d19b commit d3d6c46

File tree

3 files changed

+576
-194
lines changed

3 files changed

+576
-194
lines changed

docs/docs/cmd/spo/list/list-view-add.mdx

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,33 @@ m365 spo list view add [options]
3030
`--title <title>`
3131
: Title of the view to be created for the list.
3232

33-
`--fields <fields>`
34-
: Comma-separated list of **case-sensitive** internal names of the fields to add to the view.
33+
`--type [type]`
34+
: Type of the view. Possible values are: `list`, `calendar`, `gallery`, `kanban`. Defaults to `list`.
35+
36+
`--fields [fields]`
37+
: Comma-separated list of **case-sensitive** internal names of the fields to add to the view. Optional when `type` is set to `calendar`.
3538

3639
`--viewQuery [viewQuery]`
3740
: XML representation of the list query for the underlying view.
3841

42+
`--calendarStartDateField [calendarStartDateField]`
43+
: Internal name of the field that contains the start date of the calendar event. Required when `type` is set to `calendar`.
44+
45+
`--calendarEndDateField [calendarEndDateField]`
46+
: Internal name of the field that contains the end date of the calendar event. Required when `type` is set to `calendar`.
47+
48+
`--calendarTitleField [calendarTitleField]`
49+
: Internal name of the field that contains the title of the calendar event. Required when `type` is set to `calendar`.
50+
51+
`--calendarSubTitleField [calendarSubTitleField]`
52+
: Internal name of the field that contains the subtitle of the calendar event.
53+
54+
`--calendarDefaultLayout [calendarDefaultLayout]`
55+
: Default layout of the calendar view. Possible values are: `month`, `week`, `workWeek`, `day`. Defaults to `month`.
56+
57+
`--kanbanBucketField [kanbanBucketField]`
58+
: Internal name of the field that contains the bucket for the Kanban board view. Required when `type` is set to `kanban`.
59+
3960
`--personal`
4061
: View will be created as personal view, if specified.
4162

@@ -53,32 +74,54 @@ m365 spo list view add [options]
5374

5475
## Remarks
5576

77+
:::tip
78+
5679
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.
5780

81+
:::
82+
5883
## Examples
5984

60-
Add a view called _All events_ to a list with specific title.
85+
Add a list view called to a list with specific title.
86+
87+
```sh
88+
m365 spo list view add --webUrl https://contoso.sharepoint.com/sites/Sales --listTitle "Customers" --title "All customers" --fields "LinkTitle,Country,Sector,Country,Address,Contact" --paged
89+
```
90+
91+
Add a gallery view as default view to a list with a specific URL.
92+
93+
```sh
94+
m365 spo list view add --webUrl https://contoso.sharepoint.com/sites/Sales --listUrl "/Lists/Customers" --title "All customers" --type gallery --fields "LinkTitle,Country,Sector,Country,Address,Contact" --paged --default
95+
```
96+
97+
Add a view with defined filter and sorting.
98+
99+
```sh
100+
m365 spo list view add --webUrl https://contoso.sharepoint.com/sites/Sales --listTitle "Customers" --title "Transport customers" --fields "LinkTitle,Country,Country,Address,Contact" --viewQuery "<OrderBy><FieldRef Name='LinkTitle' Ascending='TRUE' /></OrderBy><Where><Eq><FieldRef Name='Sector' /><Value Type='Text'>Transportation</Value></Eq></Where>" --paged
101+
```
102+
103+
Add a gallery view as personal view.
61104

62105
```sh
63-
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
106+
m365 spo list view add --webUrl https://contoso.sharepoint.com/sites/Sales --listTitle "Customers" --title "All customers" --type gallery --fields "LinkTitle,Country,Sector,Country,Address,Contact" --paged --personal
64107
```
65108

66-
Add a view as default view with title _All events_ to a list with a specific URL.
109+
Add a calendar view with month layout.
67110

68111
```sh
69-
m365 spo list view add --webUrl https://contoso.sharepoint.com/sites/project-x --listUrl "/Lists/MyList" --title "All events" --fields "FieldName1,Created" --paged --default
112+
m365 spo list view add --webUrl https://contoso.sharepoint.com/sites/Sales --listTitle "Events" --title "All events" --type calendar --fields "EventType,InternalExternal" --calendarStartDateField EventStartDate --calendarEndDateField EventEndDate --calendarTitleField LinkTitle --paged
70113
```
71114

72-
Add a personal view called _All events_ to a list with a specific ID.
115+
Add a calendar view with week layout and subtitle.
73116

74117
```sh
75-
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
118+
m365 spo list view add --webUrl https://contoso.sharepoint.com/sites/Sales --listTitle "Events" --title "All events" --type calendar --fields "EventType,InternalExternal" --calendarStartDateField EventStartDate --calendarEndDateField EventEndDate --calendarTitleField LinkTitle --calendarSubTitleField Location --calendarDefaultLayout week --paged
76119
```
77120

78-
Add a view called _All events_ with defined filter and sorting.
121+
Add a Kanban board view.
79122

80123
```sh
81-
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
124+
m365 spo list view add --webUrl https://contoso.sharepoint.com/sites/Sales --listTitle "Tasks" --title "All tasks" --type kanban --fields "Title,AssignedTo" --kanbanBucketField Status --paged
82125
```
83126

84127
## Response

0 commit comments

Comments
 (0)