Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

How to Create a View in a document library When a new Page is added to the Site Pages Library

I am working on a site design that uses individual pages for projects. Each page will have a specific project number in the name that I would like to use to create a view in several document libraries on the site so that the page will be able to display the documents related to that project.  Any thoughts?

Super User
Super User

@jrtraylor You can simply add a lookup column in each view. This is simple ask, you should not make it complicated according to me.


Lookup to Site Pages library and title column(which has some code in your case)



If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

@jinivthakkar, thanks for the response. However what i am looking for is a flow to create views automatically when the New Page is created. We will have a large number of sites based on our list of customers which can have a large number of projects for each customer. I was going to set the customer sites up as Hubs and then have Project Sites Created and associated to the customer then i would not need to worry about associating documents to projects since the Project site would be dedicated to the Project. Sadly I was asked to keep the number of sites down and to use just a customer site to organize things by project and the amount of work required to create new projects to a minimum.  I came up with the idea to use Pages instead of sites and using a Grouped View based on the Project # column is unacceptable, they want to only see documents and SharePoint List entries related to the project of the page they are currently on. We will have about 15-20 libraries per project So if I could automate the view creation in the libraries based on when the Project Page is created it will speed things up a lot. I will still need to have the pages updated manually to point to the correct view but a lot of work will be cut out if the view is created automatically.

@jrtraylor just check this link, it has details how you create a column and add it to view.


Hope this helps !! 


@jinivthakkar - Again thanks but I am not trying to create a column with Power Automate although it is nice to have some information on how to do it if I ever need to. I want to make a view in different libraries when a new page is added to the library. I want the view to have the same name as the page that was created and only show the documents in the libraries that have the page title in a Project # column. The documents will be added to the libraries and a Project # will be added for filtering in the different views. 

Helper I
Helper I

Know this is an old post, but this is exactly something I am trying to implement.  I don't see any further suggestions for accomplishing this but hoping someone might have some new ideas?  My business is this:


Users will fill out a form which will populate a SharePoint list.  The form will include several key details namely project name.  Once submitted hope to accomplish the following:

1 - new folder created in document library

2 - new library view = to project name is created

3 - new site page is created which has pre-determined webparts, one being the document library which should reference newly create view in step 3 above


Hoping this is doable.

Following up on this as I was able to create a solution using concepts from the following sources.


I have successfully created a flow that is triggered when a new item is added which creates specific items in a separate task list, a new view in that list, a primary document set with specific subfolders, a new view in the document library, and a site page with web parts that point to the newly created views.


One note, I needed to modify the view query from the c-sharp corner source as the syntax provided would create the new view but it wouldn't be "accessible".  I would have to go and edit the new view and save it in order for it to be accessible.  Using suggestion from Ludovic Perrichon post I was able to get the viewquery syntax and then was able to modify it to fit.


c-sharp view query syntax:

<Where><Eq><FieldRef Name="Company" /><Value Type="Text">@{triggerOutputs()?['body/Title']}</Value></Eq></Where>


modified view query syntax:

<Where><Eq><FieldRef Name=\"Company\" /><Value Type=\"Text\">@{triggerOutputs()?['body/Title']}</Value></Eq></Where>


Adding "\" before and after the field references was enough to not only create the view but make it accessible without any further steps.


For the youtube reference it was a great walkthrough of how to create a site page template and then use that source code to automate the page creation process.  I did add another action to the flow that would actually publish the new page.  The walkthrough ends with the process to just save the page as a draft requiring a user to actually publish it once they viewed it.  By adding one more POST http request with the "/publish" statement was enough to take care of that.



Hope this information can be of use to someone else in the future!

Helpful resources

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022- Season 2 has kicked off!

Users online (3,533)