"m365 spo list view add" -> add support for viewtype = calendar/gallery/board
Currently the command only supports adding views, that are list based. Would be great if we had the ability to create calendar/gallery/board views as well
Thank you @MissHerku for the great suggestion! We'll have a look to see if we can enhance the command with these extra types.
Did some research, my proposal on how to update the spo list view add command.
| Option | Description |
|---|---|
--type [type] |
Type of the view. Possible values: list, calendar, gallery, kanban. Defaults to list. |
--calendarStartDateField [calendarStartDateField] |
Field name that will be used as the start date on the calendar. Only specify this field when option type is set to calendar. |
--calendarEndDateField [calendarEndDateField] |
Date field name that will be used as the end date on the calendar. Only specify this field when option type is set to calendar. |
--calendarTitleField [calendarTitleField] |
Date field that is used as the title in the calendar view. Only specify this field when option type is set to calendar. |
--calendarSubTitleField [calendarSubTitleField] |
Field that is used as the subtitle in the calendar view. Only specify this field when option type is set to calendar. |
--calendarDefaultLayout [calendarDefaultLayout] |
Specifies the default layout for the calendar view. Valid values are: month, week, workWeek, day. Defaults to month. Only specify this field when option type is set to calendar. |
--kanbanBucketField [kanbanBucketField] |
Choice field name that is used to define buckets. Only specify this field when option type is set to kanban. |
Examples:
Create a calendar view with week as default layout
m365 spo list view add --webUrl https://contoso.sharepoint.com/sites/project-x --listTitle "Test" --title "All events" --type calendar --calendarStartDateField StartDate --calendarEndDateField EndDate --calendarTitleField Title --calendarSubTitleField SubTitle --calendarDefaultLayout week
Create a gallery view
m365 spo list view add --webUrl https://contoso.sharepoint.com/sites/project-x --listTitle "Test" --title "All events" --type gallery --fields "FieldName1,FieldName2,Created,Author,Modified,Editor"
Create a Kanban board
m365 spo list view add --webUrl https://contoso.sharepoint.com/sites/project-x --listTitle "Test" --title "All events" --type gallery --fields "FieldName1,FieldName2,Created,Author,Modified,Editor" --kanbanField FieldName1
@MissHerku would this work for you? @pnp/cli-for-microsoft-365-maintainers, any comments?
No comments, let's do this. Awesome work @milanholemans
@milanholemans Yes! Sorry for late response. Can't wait to try it out!! I think I may have one more feature request (to be able to update the viewQuery via "m365 spo list view set", but perhaps I should create a new issue for that!?
@milanholemans Yes! Sorry for late response. Can't wait to try it out!! I think I may have one more feature request (to be able to update the viewQuery via "m365 spo list view set", but perhaps I should create a new issue for that!?
Hi @MissHerku, the command spo list view set supports unknown options. This means that you can specify any option to the command and we'll try to update that property on the view object. So in your case you should be able to do something like: m365 spo list view set --webUrl 'https://....' --listTitle '...' --id '....' --ViewQuery '<View><Query><Where><Eq><FieldRef Name='Status' /><Value Type='Choice'>Approved</Value></Eq></Where></Query></View>'
Maybe this is something we should visualize a bit clearer in the docs.
@milanholemans Yes! Sorry for late response. Can't wait to try it out!! I think I may have one more feature request (to be able to update the viewQuery via "m365 spo list view set", but perhaps I should create a new issue for that!?
Hi @MissHerku, the command
spo list view setsupports unknown options. This means that you can specify any option to the command and we'll try to update that property on the view object. So in your case you should be able to do something like:m365 spo list view set --webUrl 'https://....' --listTitle '...' --id '....' --ViewQuery '<View><Query><Where><Eq><FieldRef Name='Status' /><Value Type='Choice'>Approved</Value></Eq></Where></Query></View>'Maybe this is something we should visualize a bit clearer in the docs.
Didn't know! that's great!