cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 175 members 5,131 guests
Please welcome our newest community members: