cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Need Help Extracting Number from Filename SP Document Library

I'm having trouble creating a flow to update a list item in Sharepoint with a 'Revision Number' of a file created/modified in a Sharepoint library.

 

Background

We have a folder with a set of drawings that are updated. New drawings will be transferred into this folder with a file name that is composed like this: "Sheet A.A104 Rev 3 - L1 Floor Plan".

 

I am updating a 'Register' of all drawings with sheet name, description and revision number - only the revision number changes.

 

I want to update the revision number property of the respective drawing item in the list when a new drawing is created.

 

I have tried to figure out the syntax of extracting the revision number from the file name with little luck. Is there anyone who might know how to get that info and update an item property with it?

 

Thanks,

Ethan

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @Anonymous,

 

Do you want to update the revision number property of the respective drawing item when a new drawing is created in your SharePoint library?

 

I have created a SharePoint list and a SharePoint library on my side, the data structure of it as below:9.JPG

 

10.JPG

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, specify Site Address and Library Name.
  • Add a "Get items" action, specify Site Address and List Name.
  • Add a "Filter array" action, From set to output of the "Get items" action, click "Edit in advanced mode", type the following formula:
@equals(item()?['Title'], split(split(triggerBody()?['{FilenameWithExtension}'], ' - ')[1], '.')[0])
  • Add a "Apply to each" action, input parameter set to output of the "Filter array" action.
  • Within "Apply to each" action, add a "Update item" action, specify Site Address and List Name, Id field set to following formula:
item()?['ID']

Title field set to following formula:

item()?['Title']

The Revision field set to following formula:

substring(triggerBody()?['{FilenameWithExtension}'],add(indexOf(triggerBody()?['{FilenameWithExtension}'],'Rev'),4),sub(sub(indexOf(triggerBody()?['{FilenameWithExtension}'],'-'),add(indexOf(triggerBody()?['{FilenameWithExtension}'],'Rev'),4)),1))

Image reference:11.JPG

 

12.JPG

The flow works successfully as below:13.JPG

 

14.JPG

 

15.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

3 REPLIES 3
ScottShearer
Super User
Super User

I am not quite clear on your process.

 

To be clear, you have a separate SharePoint list where you maintain a list of documents that are most current.  When a new document is added to your library, you want to find the entry for the previous version in your list and update to the latest revision.  Am I correct?

 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott
Anonymous
Not applicable

That's correct. Revision number has it's own column in the Sharepoint list.

 

Please see example images. 

Document library where new drawings will be created:

Capture.PNG

Sharepoint list where drawing number & description don't change, only revision number needs to change from the file name added to the document library:

Capture2.PNG

 

v-xida-msft
Community Support
Community Support

Hi @Anonymous,

 

Do you want to update the revision number property of the respective drawing item when a new drawing is created in your SharePoint library?

 

I have created a SharePoint list and a SharePoint library on my side, the data structure of it as below:9.JPG

 

10.JPG

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, specify Site Address and Library Name.
  • Add a "Get items" action, specify Site Address and List Name.
  • Add a "Filter array" action, From set to output of the "Get items" action, click "Edit in advanced mode", type the following formula:
@equals(item()?['Title'], split(split(triggerBody()?['{FilenameWithExtension}'], ' - ')[1], '.')[0])
  • Add a "Apply to each" action, input parameter set to output of the "Filter array" action.
  • Within "Apply to each" action, add a "Update item" action, specify Site Address and List Name, Id field set to following formula:
item()?['ID']

Title field set to following formula:

item()?['Title']

The Revision field set to following formula:

substring(triggerBody()?['{FilenameWithExtension}'],add(indexOf(triggerBody()?['{FilenameWithExtension}'],'Rev'),4),sub(sub(indexOf(triggerBody()?['{FilenameWithExtension}'],'-'),add(indexOf(triggerBody()?['{FilenameWithExtension}'],'Rev'),4)),1))

Image reference:11.JPG

 

12.JPG

The flow works successfully as below:13.JPG

 

14.JPG

 

15.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.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Top Kudoed Authors
Users online (1,124)