cli-microsoft365 icon indicating copy to clipboard operation
cli-microsoft365 copied to clipboard

"m365 spo list view add" -> add support for viewtype = calendar/gallery/board

Open MissHerku opened this issue 6 months ago • 6 comments

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

Image

MissHerku avatar May 27 '25 17:05 MissHerku

Thank you @MissHerku for the great suggestion! We'll have a look to see if we can enhance the command with these extra types.

milanholemans avatar May 27 '25 19:05 milanholemans

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?

milanholemans avatar May 28 '25 21:05 milanholemans

No comments, let's do this. Awesome work @milanholemans

waldekmastykarz avatar May 30 '25 09:05 waldekmastykarz

@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!?

MissHerku avatar Jun 03 '25 15:06 MissHerku

@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 avatar Jun 03 '25 15:06 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!?

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.

Didn't know! that's great!

MissHerku avatar Jun 03 '25 15:06 MissHerku