cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mdemarici
Frequent Visitor

Move files from my companies SharePoint Site to our clients site based on metadata tags.

My objective is to be able to upload a document in our document library, tag it with metadata including the client's name, doc type, etc. and have it automatically move to our client's site based on the tags. I think this can be done with a flow, but I am concerned that our folder structure will get in the way. 

 

Currently, our Doc Library and Clients Site's Doc Library is set up with a multi-level folder structure. There are about 400 folders in our library and about 100 in our clients sites. Would it be better to have a flat structure in order to perform this automation?

 

A visual of my companies and our client's folder structure

 

Folder 1 - Microsoft

Folder 2 - Apple

Folder 3 - AMD

Folder 4 - XYZ

 

inside of each of these folders are subfolders...

 

Folder 1 - Legal

Folder 2 - Financial

Folder 3 - Reports

Folder 4 - Transactions

 

Inside each of these folders are folders that correspond with the year. 

 

This would be the ideal scenario if everything worked correctly...

 

I (Marcus) receive documents for my clients, Daniel and Chris from a company that we both deal with, let's call it Microsoft. I download the files and navigate to the Microsoft Company folder then to the financial documents subfolder then to then 2020 folder. I drag the files into the window to upload them, hit quick edit, and tag each file with Metadata (clients name, doc type, etc). Once I am done tagging, an automated flow moves Chris's file to his SharePoint site and Mike's to his. Chris and Mike can only see documents tagged with their names, and they can also see that the document is in their Microsoft folder in the Financial Documents subfolder. 

 

Is this possible with multi-level folders? It is to my understanding I would have to map the target folder to the source folder, doing this would take a lot of time considering there are about 5 subfolders in each Company folder. Would it be better if I was working with a flat structure with only metadata columns?

 

My company and my clients are used to using the folders, I would like to figure out a way where I can keep the folder structure, but I'm unsure whether I have to map each folder or if there is a better way to handle this.  I can potentially convince management and clients to switch to a flat structure if I can make it have a similar look and feel, navigation, etc. 

 

Thank you for reading!!

1 ACCEPTED SOLUTION

Accepted Solutions

Hello @mdemarici 

Thank you for the information. Let me try and make it clearer.

I use a string variable to build the folder path, so after your trigger, initialize a variable to hold the folder path - initial value usually is the document library. See my screenshots below. I have included only the parts where I ensure that the folder path in which the document is to be moved, exists before the move file action.

MoveFileToTargetACustomer.png 

First part is to get the customer value from the file properties and add it to my folder path variable (TargetPath).

I then check to see if the folder exists already and if it does, I just continue, but if it does not exist then I create it.

 

The same I do with the file property Service ... add to variable, check that folder exists, create if not.

MoveFileToTargetBService.png

Do the same for all your properties/folder levels 😉

At last just use a Move file action to move your file from its path to the folder path variable.

Kind regards, John

View solution in original post

10 REPLIES 10
JohnAageAnderse
Memorable Member
Memorable Member

Hello @mdemarici 

I can't decide for you what you and your partners will do, but I can give a little information on how we are using Flow to move our documents around and the reason for it. Please note that we mostly are using Classic SharePoint still 🙂

 

In the beginning we had the Shared Documents library as a flat structure, no folders at all. At the same time we have a lot of different customers for which we need to have specific documentation. We were forced to include the customer name in the documents filename, so as not to have a conflict on naming.

 

We had already added several properties to the documents library - customer, service, tags. Also several content types were defined. As our colleagues works in teams and each teams provides support for one or more services, the above allowed us to create team pages and team customer pages which presented their customers and the documents related to customers and services - we introduced a minimal click solution for our teams - 1st click on customer, 2nd click on the document.

 

After some time, to avoid the filename conflict, we decided to introduce folders in the document library. We went with 3 levels, customer, service, content type. The introduction of folders had no impact on the presention in the team customer pages.

 

A flow was setup to automatically move a document into the correct folder based on the properties. By now having documents inside this folder structure, our colleagues can now name their documents without a customer name.

 

Hope the above gives you some ideas. Kind regards, John

Hi John, 

 

Thank you for taking the time to reply. I was able to get a flow going that moves the documents to a folder based on tags, any tips on moving the files to sub folders?

 

It sounds like our situations are similar. Us and our clients receive documents from a fairly large number of other companies. This semi large number of company names would be the names of the sub-folders. Do you have any insight as to how to write the flow to go to sub-folders? Do I have to write a condition for each company, or is there a way to do it with fewer conditions?

 

right now my flow is like this 

 

get created doc --> pull metadata --> if client abc, move to client abc folder 

 

What would be the best way to do this..

 

get created doc --> pull metadata --> if client abc, move to client abc folder --> move to company name folder within client abc folder

 

Thanks again for the help! @JohnAageAnderse 

Hello @mdemarici 

We use a known folder structure, so even when a new customer comes in or they start to receive a service, the flow will automatically create the needed folder structure.

The flow starts by building the folder path - first as just the customer name, checks that the folder exists, creates it if not - then takes the next level from the properties - service, adds it to the folder path, checks that the folder exists, creates it if not - and so on.

A document can end up in either the customer folder, the service folder or in the content type folder. The reason some documents ends up in the customer folder, is that they are not related to a service.

My best suggestion is for you to discuss your needed structure with your colleagues and then implement a solution for it.

Kind regards, John

Thank you, John. That description was very helpful to me!

Hi @JohnAageAnderse I'm trying to mimic your description, but I am unsuccessful. would you mind sending me a screenshot of how the flow starts by building the path?

 

Do you use the "create a new folder"  process?

Hello @mdemarici 

Thank you for the information. Let me try and make it clearer.

I use a string variable to build the folder path, so after your trigger, initialize a variable to hold the folder path - initial value usually is the document library. See my screenshots below. I have included only the parts where I ensure that the folder path in which the document is to be moved, exists before the move file action.

MoveFileToTargetACustomer.png 

First part is to get the customer value from the file properties and add it to my folder path variable (TargetPath).

I then check to see if the folder exists already and if it does, I just continue, but if it does not exist then I create it.

 

The same I do with the file property Service ... add to variable, check that folder exists, create if not.

MoveFileToTargetBService.png

Do the same for all your properties/folder levels 😉

At last just use a Move file action to move your file from its path to the folder path variable.

Kind regards, John

View solution in original post

Hi @JohnAageAnderse 

Thank you for your continued support in this.

 

One quick question on the creation of the folder using the folder path string variable.

 

I'm getting an error that the folder name contains characters that are not supported when I use the folder path target variable in the create new folder step. Pic below. is there another way to use that variable in the create folder step so that it works?

 

 I also noticed in your pictures earlier, you used the get folder metadata using path step, I tried that and was also getting some errors as the target path was "not found" and for some reason, it didn't move onto the next step even when the "run after" said to move on whether it succeeds or fails

 

to understand this correctly, the target path is where the document needs to be added, the destination aka the customer folder, correct? if so, if it's not created yet, is the "get Folder metadata from the target path" step going to automatically fail, and that's why you have the "run after" step?

 

Thank you so much again, your last reply was a breakthrough for me and I feel like I am very close to solving this now. 

 

 

Hello @mdemarici 

Good to see that you are moving forward 🙂

 

About the folder path - yes, it must not contains any unsupported characters - you will have to look up what they are. I do change one character due to us having danish customers also and their name may have a slash "/" in it (a company type "A/S"), so we decided to just remove it.

 

The reason we are checking for the existence of a folder is that the customer may be new, or the service may be newly signed up to, so the folder may not yet exist.

 

By the way, in your condition it says "TargetPath contains TargetPath"?? It should be "<get folder meta data using path>Id is not equal to null (expression)" - testing if the action returned anything (old solution before Configure run after became available).

Kind regards, John

Thanks! @JohnAageAnderse 

 

Thanks for the clarification, so I have to change the characters inside the variable itself, the fact that im putting the variable in the folder path box isn't the issue? 

 

The if TargetPath contains TargetPath is actually TargetPath contains TargetPath2. I ended up making another variable that didn't have the customer name as a folder at the end because I was not sure why I was getting the error on the "Get folder Metadata using path" Step. it was saying it didn't exist. 

Was I running that step correctly? I was using the target path as the folder for the step. 

 

Thanks!

Hello @mdemarici 

The step Get folder metadata using path may succeed or may fail - the condition after checks to see if it was a success (Yes branch) or a failure (No branch).

Today with the features available, you actually don't need the condition, but can use a scope to hold the No branch steps and then configure the Scope to run only after a failure in the Get folder metadata using path step. (A future task for me to update our flow).

Kind regards, John

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (2,996)