Today some people who are running targeted release on their M365 Tenant have been able to add the Board view to new and existing Microsoft/SharePoint Lists. I wanted to automate this creation of the Board View and following on from a previous blog post I did where I created a Modern Calendar on a list. I realised to add board view it followed the same pattern – using SharePoint Rest API. Through using the Edge Developer tools I figured out the JSON & Rest call required and that the view type was ViewType2: “KANBAN”.
To create the board view manually there is a new Board button in the Modern Create View screen.
Creating the list view manually however is no fun – I want to automate it!Leon Armston © 2022
Create Board View on an Existing List using PnP PowerShell
You may have an existing list you want to use for board view. If you don’t already have a list you could use one of the Template lists included in your tenant i.e. Work progress tracked.
The steps to create a new board view using PnP PowerShell are below:
- Below Is the JSON body required for the add View REST API call
Note the following regarding the REST API body listed above
- RowLimit is set to 500
- ViewData has a FieldRef entry – replace the Name Priority with the field you wish to organize the board by
- ViewType2 is KANBAN
- ViewTypeKind is 1 – which maps to HTML.
- Query can be set if required.
- Use the PnP command Invoke-PnPSPRestMethod to hit the /Lists/Views/Add end point using the method Post and then use the JSON body we just crafted above.
- Finally set the newly created “Board” view to be default for list for normal and mobile modes.
The modern calendar view is now created:
Full code in a Github Gist below where I have made some improvements to the code to make it more automated :
Bonus – Power Automate/Logic Apps Version
This could also be done using the Send an HTTP request to SharePoint action (see image below – click on image for more details). Change the highlighted parts to reflect your site, list and view.
Here I showed you using PnP.PowerShell & briefly Power Automate to create a Board view on a list. I’m very excited for board view and is this a potential Microsoft Planner killer! I used the web developer tools in Microsoft Edge to see what REST API calls were being made to create the board view and then replicated.
Have fun automating this and hope it is helpful in your environment!