cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tianaranjo
Level 8

Need Help Extracting Number from Filename SP Document Library

Greetings,

 

Scenario:  When a new item is added to a SP list via the app, a flow kicks off creating a supporting folder in a SharePoint doc library.  The filename is the key id for both items.  Within the doc folder, files and photos will be stored.  

 

Question:  How can I retrieve the filename for the last item (photo)  in the folder so, if a user 'Edits' an item via the app and adds a new photo, the filename will be based on the last item in the library.  For example, I currently have 

Collect(
    PhotoList, 
    {Photo: imgMediaPhotos.Image,
     Filename: Concatenate(photoName.Text, Text(CountRows(PhotoList)+1), ".jpg")}
)

An example of the folder filename is: 

  • https://SP_Site_Name/DocumentLibraryName/temp.txt/0159_0035.700A

And the respective files in the folder will be named accordingly:

  • https://SP_Site_Name/DocumentLibraryName/temp.txt/0159_0035.700A/0159_0035.700A-1
  • https://SP_Site_Name/DocumentLibraryName/temp.txt/0159_0035.700A/0159_0035.700A-2

With the example above, if a user Edits a record and adds a new photo, the new photo filename should be 0159_0035.700A-3

The method I used for adding photos was based on this video by @paul_culmsee

Thank you!

2 ACCEPTED SOLUTIONS

Accepted Solutions
KickingApps
Level 8

Re: Need Help Extracting Number from Filename SP Document Library

Hoping to raise this back up to the top and attract the attention of a PA wizard to help me solve.  

 

Thanks!

View solution in original post

Community Support Team
Community Support Team

Re: Need Help Extracting Number from Filename SP Document Library

HI @tianaranjo,

 

Could you please share a screenshot about your flow's configuration?

Do you want to retrieve the file name for the last item (photo file) in the folder within your flow or app?

Further, could you please show more details about the PhotoList collection that you mentioned?

 

If you want to retrieve the file name for the last item (photo file) in the folder within your app, you must find all photo files have been existed within the corresponding folder (e.g. 0159_0035.700A ) firstly.

 

I assume that you want to add a new photo file within the 0159_0035.700A  folder, I have made a test on my side, please take a try with the following workaround:

8.JPG

 

9.JPG

 

Set the OnVisible property of the first screen of the app or the OnSelect property of Button control to following formula:

ClearCollect(
PhotoCollection,
SortByColumns(
Filter(Reporting,StartsWith('{FilenameWithExtension}',"0159_0035.700A"),EndsWith('{FilenameWithExtension}',".jpg")),
"ID",Ascending
)
)

Note: The Reporting represents the SP library within my SP site.

 

On your side, you should type the following:

ClearCollect(
PhotoCollection,
SortByColumns(
Filter(YourSPLibrary,StartsWith('{FilenameWithExtension}',"0159_0035.700A"),EndsWith('{FilenameWithExtension}',".jpg")),
"ID",Ascending
)
)

 

Set the OnSelect property of the "Collect" button to following formula:

Collect(
    PhotoList, 
    {
Photo: UploadedImage1.Image, /* On your side, it is imgMediaPhotos.Image */ Filename: Concatenate(First(Split(First(PhotoCollection).'{Name}',"-")).Result,"-" ,Text(CountRows(PhotoCollection)+1), ".jpg")
} )

 

My SP library structure as below:10.JPG

When I click the "Collect" button, the PhotoList collection as below:11.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

4 REPLIES 4
KickingApps
Level 8

Re: Need Help Extracting Number from Filename SP Document Library

Hoping to raise this back up to the top and attract the attention of a PA wizard to help me solve.  

 

Thanks!

View solution in original post

Community Support Team
Community Support Team

Re: Need Help Extracting Number from Filename SP Document Library

HI @tianaranjo,

 

Could you please share a screenshot about your flow's configuration?

Do you want to retrieve the file name for the last item (photo file) in the folder within your flow or app?

Further, could you please show more details about the PhotoList collection that you mentioned?

 

If you want to retrieve the file name for the last item (photo file) in the folder within your app, you must find all photo files have been existed within the corresponding folder (e.g. 0159_0035.700A ) firstly.

 

I assume that you want to add a new photo file within the 0159_0035.700A  folder, I have made a test on my side, please take a try with the following workaround:

8.JPG

 

9.JPG

 

Set the OnVisible property of the first screen of the app or the OnSelect property of Button control to following formula:

ClearCollect(
PhotoCollection,
SortByColumns(
Filter(Reporting,StartsWith('{FilenameWithExtension}',"0159_0035.700A"),EndsWith('{FilenameWithExtension}',".jpg")),
"ID",Ascending
)
)

Note: The Reporting represents the SP library within my SP site.

 

On your side, you should type the following:

ClearCollect(
PhotoCollection,
SortByColumns(
Filter(YourSPLibrary,StartsWith('{FilenameWithExtension}',"0159_0035.700A"),EndsWith('{FilenameWithExtension}',".jpg")),
"ID",Ascending
)
)

 

Set the OnSelect property of the "Collect" button to following formula:

Collect(
    PhotoList, 
    {
Photo: UploadedImage1.Image, /* On your side, it is imgMediaPhotos.Image */ Filename: Concatenate(First(Split(First(PhotoCollection).'{Name}',"-")).Result,"-" ,Text(CountRows(PhotoCollection)+1), ".jpg")
} )

 

My SP library structure as below:10.JPG

When I click the "Collect" button, the PhotoList collection as below:11.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

KickingApps
Level 8

Re: Need Help Extracting Number from Filename SP Document Library

@v-xida-msft I missed this somewhere along the way.  Going to try this now.  I'll accept once I have it working.  Thank you!

luuminhvuong93
Level: Powered On

Re: Need Help Extracting Number from Filename SP Document Library

If using Filter ...StartWith,  I have a delegation warning 😞

with more than thousand photos, not sure if this can work

Helpful resources

Announcements
Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Microsoft Business Applications Virtual Launch

Join us for the Microsoft Business Applications Virtual Launch Event on Thursday, April 2, 2020, at 8:00 AM PST.

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (3,797)