Modern SharePoint Page Approval with Power Automate: Message Optional

Overview

The current iteration of page approvals in SharePoint Online using Modern pages and news is handled by Power Automate – and the integration is pretty slick. Kudos to the Microsoft teams responsible for it (SharePoint + Power Automate).

Approval Flow

Once an approval flow has been configured and a user submits a page, the user is prompted by the following panel:

Approval Panel

Note here that the Message field is required. In many cases, this is fine. There are some circumstances however where site owners may want to make the Message field optional.

The Quick Steps

Without getting into all the nitty gritty, here’s how it’s done (at least one approach):

  1. Go into Power Automate and open the approval flow
  2. On the first step of the flow, expand the “For a selected item” step
  3. For the “Message” property, select the menu (three dots) button and select “Make the field optional”)
    Flow Field Optional
  4. Expand the scope (mine is called “Scope 2”), and the “Start and approval” step
    Approval Details
  5. Click on the “Details” expression (circled above) – which opens the panel for updates
    Approval Expression
  6. Update the expression to include a question mark (“?”) after “triggerBody()” and before “[‘text’]”.
    Expression Text
  7. Click “Update” (see above)
  8. Save the flow, and test

When an approval is submitted, the Message field in the panel should now show as “not required” – no asterisk should be visible. The panel should allow users to leave the field blank and “Submit” the page for approval without error.

Not Required

The Details

One example I’ve seen where this is applicable is a site where there is a content management team that does a significant amount of the page creation, but also has folks outside the normal content team that submit content from time to time. Approval is needed. When the main content team is creating pages – they want to get through it and keep moving. The Message field turns into a “junk” field, they keyboard smash or put some useless text in the field in order to submit the page. This is irritating for users and inserts bad/silly data into the system. Rather than remove the field outright, we’d still like to have it available when needed – by folks outside the team, for example.  

Let’s review how this works. Open up the flow. Then expand the “For a selected item” step (Step 3 above).

Changing the Message field to “Make the field optional” seems pretty straight-forward. It will even work for some flows. But by itself this change will not work for all scenarios. The flow will fail when the Message field is left blank because later in the flow a step attempts to use the text IN the field. When that text is blank, the flow fails. 

If you run/test the flow with no Message text, you can open the failed instance of the flow to see where the error occurred. The scope will show an indication that something is wrong. When you expand the scope you can see the error on the “Start an approval” step. This flow fail is also followed up by a “Something went wrong…”  email from Microsoft Flow.

Broken Flow

Looking at the error message, there’s something wrong with ‘text’, which looks like it’s pointing back to the Message field we changed.

If we test run the flow again, and put text in the message, the flow works fine.

Looking at steps 4-6 above, you can see where the additional change needs to be made – adding a question mark to the expression. This syntax (the “?”) allows the expression to evaluate the Message field – [‘text’] – as Null when it is empty. Before we added the question mark the expression didn’t know what to do with a blank Message field and failed the flow. 

Note: I haven’t been able to find official documentation anywhere on what the “?” syntax is within expressions, how to use it, when to use it, etc. Maybe my search skills are falling off. If you find something from Microsoft, let me know and I’ll update this post and references for it. Until then I’ll include what I did find below.

References

Paul Stork has the most information I’ve seen on the use of the question mark (?)  thus far as seen in this community post:
Solved: Use of Question Mark(?) in expressions – Power Platform Community (microsoft.com) 

Another blog that references the question mark with regards to a Power Automate expression
Power Automate – how do we check if a property exists in the object? | It Ain’t Boring (itaintboring.com)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.