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!

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

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

Highlighted
luuminhvuong93
Level: Powered On

Re: Need Help Extracting Number from Filename SP Document Library

If using Filter ...StartWith,  I have a delegation warning Smiley Sad

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

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Next Wednesday, August 21st at 8am PDT

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

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

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

SixthImage

Power Summit Australia 2019

August 20-23rd 2019

Users Online
Currently online: 274 members 3,559 guests
Please welcome our newest community members: