cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SylvieLet17
Responsive Resident
Responsive Resident

Get File Properties from File Name

Hi all, I am trying to achieve something in Flow that was so simple in SharePoint Designer.

I have created a workflow on Library1, and I need it to check Library2 for any file with the Name of the document in Library1, and get that file's properties. Specifically I want the file URL.

In SP Designer I would just create a workflow variable from Library2 using field "Name" and I could choose whatever file property I wanted. enter image description here

But with Flow the Get File Properties seems to throw tons of errors and basically crashes the workflow. It also doesn't allow me to select just one property, but instead proceeds to 'get' all the properties. enter image description here

My desired result is:

When a file is created in Library1, check if a file with the same name exists in Library2. If it exists, get file in Library2's URL and send it in an email.

Can anyone show me an easier way to achieve what I am trying to do? 

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @SylvieLet17,

 

I have made a test on my side and please take a try with the following workaround:

  • Add a "When a file is created (properties only)" trigger, Library Name set to MyLibrary1.
  • Add a "Get file metadata" action, File identifier field set to Identifier dynamic content of the trigger.
  • Add a "Get files (properties only)" action, specify Site Address, Library Name set to MyLibrary2.
  • Add a "Apply to each", input parameter set to output of "Get files (properties only)" action.
  • Within "Apply to each", add a "Get file metadata 2" action, File identifier field set to Identifier dynamic content of "Get files (properties only)" action.

         Add a Condition, click "Edit in advanced mode", type the following formula:

@equals(body('Get_file_metadata_2')?['DisplayName'], body('Get_file_metadata')?['DisplayName'])

Within "If/yes" branch of Condition, add a "Send an email" action, Body field set to Link to item dynamic content of "Get files (properties only)" action.

 

Image reference:24.JPG

 

25.JPG

 

 

The flow works successfully as below:26.JPG

 

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-xida-msft
Community Support
Community Support

Hi @SylvieLet17,

 

I have made a test on my side and please take a try with the following workaround:

  • Add a "When a file is created (properties only)" trigger, Library Name set to MyLibrary1.
  • Add a "Get file metadata" action, File identifier field set to Identifier dynamic content of the trigger.
  • Add a "Get files (properties only)" action, specify Site Address, Library Name set to MyLibrary2.
  • Add a "Apply to each", input parameter set to output of "Get files (properties only)" action.
  • Within "Apply to each", add a "Get file metadata 2" action, File identifier field set to Identifier dynamic content of "Get files (properties only)" action.

         Add a Condition, click "Edit in advanced mode", type the following formula:

@equals(body('Get_file_metadata_2')?['DisplayName'], body('Get_file_metadata')?['DisplayName'])

Within "If/yes" branch of Condition, add a "Send an email" action, Body field set to Link to item dynamic content of "Get files (properties only)" action.

 

Image reference:24.JPG

 

25.JPG

 

 

The flow works successfully as below:26.JPG

 

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Fantastic, thank you so much for this extremely clear step-by-step guide Kris. 

I've created it and indeed it is sending me the links to documents. 

I'm going to see if I can adapt this to:

1. Run on a button

2. send an approval email

3. on approval, add the link into a column in Library1

3. add a date in another column in Library1. 

 

Thanks again, this was SO helpful!

 

Sylvie

Hey Kris, 

 

I've noticed in some cases the Apply to Each function is taking a LONG time to complete. For example...it's still running from 3 days ago. Is that simply because it's a heavy command? Will this type of performance get worse as the number of files increases?

 

Thanks,

Sylvie

Anonymous
Not applicable

Sylvie,

 Without knowing for sure, I would guess that it is taking a long time because of the large number of files the 'Get files (properties only) query in the Flow. Expanding the advanced options in there it suggests filter query options, limit the number of columns returned by a view and the top number of rows to return from the query. Those are quite probably for the very reason you're suggesting I'd imagine.

Great solution to a similar problem I was having, so thanks for that! 

 

I must ask, is there a good reason why we must jump through 3 hoops to gather information that really should just be provided in the first place? Why is it that we have to use three different steps to retrieve the link??

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (2,316)