14 Nov Use Microsoft Flow to Separate Site Pages and News Posts
Requirement: News posts need to be added to a SharePoint site for a company portal. There should also be an archive of all news posts. SharePoint stores all news posts and pages in the Site Pages library. The goal was to keep customizations simple: when people select Add a page those pages are stored in the Site Pages. The news posts (stored in the same library) needed to be filtered out to create an archive of only news posts.
Overview: One of the distinguishing factors between a news post versus a regular page is that news posts have the Promoted State column value set to ‘2’. There is no way to easily create a view to filter out this value to see all news posts only.
A Microsoft Flow is used to retrieve the Promoted State value. The reason for selecting the SharePoint – When an item is created or modified action (in Step 2 below) is that when the post/page doesn’t have a title, SharePoint will assign the post/page random characters until the Title has been added. Once the Title has been added, SharePoint will update the actual post/page with the actual Title and sometimes the Promoted State isn’t initially assigned to the column.
- Create a News column in the Site Pages library
- Create a Flow that checks if the Promoted State = 2. If Promoted State = 2, update the News column with value ‘Yes’
- Create a view called News Archive that filters the Site Pages library where the News column equals ‘Yes’
1. In the Site Pages library, create a column called News. To keep it simple, choose Single line of text as the column value. (Choice could be used as the column type.)
2. Create a Flow to set the value of the News column when a news post is created.
Trigger: Even though Site Pages is a library and not a list, select the SharePoint – When an item is created or modified trigger, select the site, and type in “Site Pages” as a custom value. (Site Pages do not appear in the list of library type of triggers.)
3. Add a Condition action, Select the PromotedState column, leave the default as is equal to and type in ‘2’.
4. In the Yes branch, select the SharePoint – Update item action to set the Site Pages library News column as ‘Yes’.
5. Name the Flow and Save. The full Flow should look similar to this:
Make sure it’s turned on!
6. Back in the SharePoint Site Pages library, create a view called News Archive.
Filter the view to only show where News is equal to Yes (which will be set by the Flow).
Back on the Home Page (or a page with the News webpart), add a link to the News Archive view (or even a link to a Page with the News Archive view), then add a News post:
Add a Site Page:
The Site Pages library gets updated automatically by the Flow to flag news posts appropriately.
When the News Archive link is clicked on from the home page, only the news post items appear.
Thanks for reading!