Auto-populating columns in SharePoint for existing files and folders

Copper Contributor

Does anyone know if there is a way to auto populate columns/metadata in SharePoint with default values for existing file and folders. I have tried by going into library settings and changed the default column settings with the value I needed. It seems to be working fine for any documents that are created after changing this setting, but isn't working for existing documents that were already in SharePoint? How can I change the column values for existing files and folders please? Can I use power automate to do this or can it be done using SharePoint?
Thanks in advance

13 Replies
I think if you are using normal folders then a power automate flow would be the only option.

But you would get the desired effect If you are willing to switch your folders to "Document Sets"

https://mikehatheway.com/2022/02/17/modern-document-sets/

"Document Sets" can automatically set properties on all documents in the set.

I have tried creating a new manual tiggered workflow, then used “update file properties” but I get errors when I run it.

 


"{
"status": 404,
"message": "Could not find list item.\r\nclientRequestId: 315ca606-00ee-44ff-b38e-c6e88c145930\r\nserviceRequestId: 315ca606-00ee-44ff-b38e-c6e88c145930"
}"

I have entered the correct site address. library and the two columns I wanted the values changed in, so am at a loss why it is not working. Using the correct username account which is owner/admin access to that site too.
Anyone have any ideas?

Thank you.

Did you also enter the correct item ID in the ID Field of the "update file properties" action?
what or where would I get the correct item ID that i need to enter?
I have enter the correct *Site Address, and *Library Name. It is just the *Id that is that I have enter, but where would I get the correct value to enter there please, current I have just entered a random number?

@Brandccc 

 

You get that ID from the Trigger as a dynamic content

iütrigger.png


But you might get an endless loop if you update that file in a flow that is triggered if you update an item.... You should also insert a condition that makes sure that you don't needlessly update the item (i.e. check if the two columns already have the value you want to set)

I only get the options of choosing the likes of latitude, longitude, city, country/region, timestamp, user name and user email which I have tried but again I get errors.
The ID has to be a integer of certain length
"The 'inputs.parameters' of workflow operation 'Update_file_properties' of type 'OpenApiConnection' is not valid. Error details: Input parameter 'id' is required to be of type 'Integer/int64'. Converting the integer value '51.571610920882094' to type 'Integer/int64' will result in a loss of precision. Use the 'float()' expression if this is intended."
What kind of trigger did you use? Latitude/Longitude/City are properties of the "Manually trigger a flow" Trigger. You will need to use a SharePoint-Trigger

In order to make your usecase work with a flow you will need to

1) Create an automated Flow (Not a instant cloud flow)
2) Use the "When an item or file is modified"-Sharepoint Trigger and set that to watch your Document Library
3) Add some conditions that get the "folder path" from the trigger, decide in which folder the file is and i.e. in two variables with the properties for that folder
4) Check if the variables and the original data have the same value (you get the current values for the original data from the trigger)
5) If they are not the same, update the File using the "Update File Properties" Action. Use the ID you get from the trigger and the variables for the two values

Flows that sync informations between two sources can be a little bit complicated and error prone.

In my opinion you should alternatively take a look at "Document Sets"
https://mikehatheway.com/2022/02/17/modern-document-sets/

what or where might I get the right thing ID that I really want to enter?
I have enter the right *Site Address, and *Library Name. It is only the *Id that will be that I have enter, however where might I get the right worth to enter there please, current I have quite recently entered an irregular number?

@SvenSieverding 

Thank you for helping with me with this.

I was using a manual trigger as it would run/triggered manually and only really used once or twice. I did not create the document library,  it is a large existing library(s) which is owned by a completely different team. 
Can I get the  automated Flow to be manually triggered?

Ah... OK, sure..... In that case you should use the instant trigger "For a selected File". This Trigger will give you the ID to the selected file.
Then you can start the flow from the list. Mark the the file and then select "Automate" and then your flow from the list menus. Then your flow will be started on that File
Thank you, would that work on all files or just that selected file, what I need to do is change the columns values for 2 columns for all existing files and folders in that library?
Thanks for your help again, it is much appreciated
You're welcome :)
In that case the trigger doesn't matter and you will need to use the Sharepoint "Get Files (properties only)" action after the trigger.
This will give you all files in the library (Change the TOP-Count in that action to the maximum possible size to try to get all of you files in one go)..
Then use an "Apply to each" action with the value of the previous action as an input parameter.
You will then have access to all file properties inside the "Apply to each" loop, including the id.
Add your update action there and use that id
Thank for that, I tried doing/following your instructions but I am at a loss/can't quite figure it out.