Site icon @WonderLaura

Required SharePoint Document Metadata – Flow Trigger

In SharePoint back in the old days, there used to be a way to have fields/columns that were required for documents, and when a single document was uploaded, the user was prompted to fill in those required fields.  As you may have noticed, in SharePoint Online, documents can be easily uploaded and bulk uploaded without anything prompting you or preventing upload/check in if the required fields aren’t filled out.  The fields do show in yellow in views, but there isn’t really a way to enforce those required fields.

In this set of posts, I’ll talk about a few different options that you have in SharePoint online with Microsoft 365, and the factors involved in those various solutions, to work with the technology available, to get close to accomplishing this.  Both of these methods involve using Power Automate.

Flow Trigger Inputs

In this first method, create a flow that is triggered manually, and set required inputs which include an uploaded file.  This way, you’re not sending them to the library to upload files, the users are running this flow to upload a file.  Kinda ugly, but this is the quickest/easiest of my methods.

1.  Create a new flow, and use the trigger Manually trigger a flow.

2.  Click Add an input.  This is where you’ll add all of your required fields.  The field types here mostly match what you’re used to seeing in SharePoint regarding column types.  Email is a person field, the rest are self-explanatory.

Rename each field as you go, and there are more options when you click the ellipsis.  If you need a drop-down list, those can be found when you add a text input, as seen in this screenshot.  They will all be required fields by default, but you can choose to make any of them optional.  No, there isn’t a way to have dynamic or lookup information in here.

3.  Add an input for File.  This is the file that the user will be uploading, that your flow will place in SharePoint.  See here that I renamed my file “Statement of Work” and customized all of the field names and hint text.

4.  Add an action to initialize a variable, and call it varFileName, and make it a string.  This is where you’ll store the name of the file that gets uploaded.

For the Value, use the following expression: (I don’t recommend copying and pasting this code)

triggerBody()?[‘file’]?[‘name’]

5.  Add the SharePoint Create File action.  Use your variable as the file name, and use the dynamic file content from the trigger for the file content.  Pick the place in SharePoint where you want the file to end up.

6.  Add the SharePoint Update file properties action.  Fill in all of your SharePoint fields per the inputs that you created in the trigger.  For the Id, select the ItemId of the file you just created in the previous action.

7. Save the flow.

8.  Test the flow by running it.  Fill in all the fields, upload a file, and Run flow.

9.  Next you’ll need to give people “run only” access so that they can run the flow.  On the flow’s main screen (seen above), in the Run only users section, click Edit.  You can add people or groups.  If the users *don’t* have access to the SharePoint library where the files are being created, you can set it to run as you the flow owner when it creates the file.  In this example, I’m giving Billy access, but he doesn’t have access to that SharePoint site, so I can change the drop-down box to use this connection (with my name).  You don’t have to change this setting.  It’s only needed if the user doesn’t have access to that location in SharePoint.

10.  You’ll need the hyperlink to the flow, which you can get from the email that arrives when the flow is shared with someone.  This is the email that Billy receives.  Click Get Button.  Grab the URL of the page that it takes you to

11.  This is what the page looks like.  This URL can now be used from anywhere.  You can create a button on your SharePoint site that takes people to this page.

Again, this is fairly ugly, but pretty simple since it’s only 4 actions in the flow.  Here’s the whole thing.  Oh, and be careful about that run-only user email that gets sent.  It doesn’t give you the option to NOT send an email when sending to a group of people, so you may want to give them a head’s up if sending to many people as “run as” users.

Here’s the video where I go through these steps, starting at 3:15.  In this video, I also show how you could do something like send the file to a different document library depending on which department was selected, from a drop-down list of departments.

Exit mobile version