Approval Workflow For News

I had a client request a workflow that, on News Post creation, if it was marked to be on the home page ( Highlighted ) it would send an approval email to reject/approve the post. I had never done this before and it was tricky for me to figure out, so I hope this post will help someone with a similar situation.

The initial steps I had thought to do were:

  1. ‘When an item is created’ trigger for the workflow- pointed towards the Site Pages
  2. Add a condition to find if it is a News Post and the column ‘Highlighted’ is checked
  3. If yes, create an approval
  4. If approved approve the News Post / If rejected reject the News Post

I thought this would all work out well- but when you do the process manually it actually runs early. This is because when you go to create a news post it adds the item automatically so the workflow runs with the news post not even being filled out. This created a big problem for the workflow. The only way I could come up with to combat this was to require content approval for submitted items and then do a workflow on approval submission.

The first step to this was to go into the Library Settings of the Site Pages library, go to the Versioning Settings, and check the ‘Require content approval for submitted items?’ question. Next, select ‘Create major and minor (draft) versions’ for the ‘Create a version each time you edit a file in this document library’. This will require you to set the number of major versions you want to keep. I just selected 10*

Find more on versioning here

The next step is to create a page approval workflow. The way I did this was by selecting ‘Automate’ in the Site Pages library and clicking ‘Configure page approval flow’

This will open a panel that asks you to confirm the flow creation and you want to click ‘Create flow’. Then it shows you the details on the workflow ( the apps it uses, the type of workflow it is, and the details ) Make sure you have a green check on all of the apps and then click ‘Continue’. Add a name for the workflow and the people you want to be able to approve these items. ( I added myself as the approver and went with the default name- but you can change it later )

The next step is to go into Power Automate > My Flows > Cloud Flows > Submit SharePoint page for approval > Edit. You’ll notice this created a big workflow- this just saved us a bunch of time in our process.

The workflow works like this:

For a selected item – On submission for the item trigger to start the workflow

Scope – Allows greater handling and more detailed error results

Get File Properties – This gets the columns (properties) that the item has

Get file metadata – This gets the ETag of the file (Entity tags)

Set Content Approval status – This uses the ETag of the item to set it’s approval status to pending (pending as submitted)

Start an approval – This starts an approval and then the condition handles the response ( approve / reject )

Send me an email notification – If the workflow failed it will send an email notification to the creator of the workflow

Configure the Workflow for News Posts

Since this will work for more than just News Posts ( Pages, Links, etc. ) we need to add a condition to make sure we’re dealing with only News Posts and that it was marked as a Highlighted feature.

The first step is to add a Yes/No column named Highlighted to the Site Pages library.

Next, lets add that condition we talked about in the workflow. Right after the ‘Set content approval status – Pending’ action add a condition action. Something to keep in mind is that Pending News Posts have a promoted state of 1, Approved News Posts have 2 as their promoted state, and Pages have a promoted state of 0. This is how we’ll figure out if the selected item is a News Post.

You can see the promoted state for these by showing the Promoted State column in the Site Pages ( click Add column > Show/hide columns )

In the condition add the dynamic content ‘Promoted State’ found in the Get file Properties section and make sure to make the operator ‘is equal to’. It should be equal to 1*

Next, add another row- Highlighted ( from the dynamic content found in the Get file Properties section ) is equal to ‘true’. That way it gets only the news posts we want.

In the If Yes path add an ‘Update item’ action and set the Highlighted column to false ( just fill only that section out and the required ). Make sure you enter ‘Site Pages’ as the list name as a custom value! The reason we’re doing this is because, say you have a webpart that pulls back these Highlighted News Posts- if the approval takes more than a second this News Post will show up on that webpart. This is a precaution to having that happen in your environment.

Moving on, we need to create an approval and do a condition based on the result it gives. You can just copy the original ‘Start an approval’ and condition the workflow gave you as it’s already filled out and then move the originals into the ‘If No’ path.

The next step is to, in the If Approved path of the condition in the If Yes path, add another update item to set the Highlighted column to true. This will cause a problem- We need to get the ETag again because the item was updated and we need to set the approval status to pending again to set it to approved. That means you need to repeat the Get File properties, get file metada, and ‘Set content approval status – Pending’ again. This time it will end with setting the content approval status to Approved. Below is a visual because that might be confusing*

Conclusion

That’s it! Approval workflows can be tricky, but we conquered them for today! I hope this blog post helped you if you found yourself in a similar situation or you learned something new!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: