cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ErikH63
Resolver I
Resolver I

Flow on a SharePoint list

Hello,

 

I have been trying to build a manual one time run flow that copies attached files in a SharePoint list to a Sharepoint document library where the attachments are added to subfolders of the document library, but I have been unsuccessful.  

 

I have about 300 list items each of which have several attachments.  The flow needs to read each list item and copy  the attachments to a subfolder that is created from two fields in the list.  

 

For example, here are a few items in the list

ErikH63_0-1616121384735.png

 

 

 

 

 

 

 

 

 

 

 

So if I take the first item as an example the flow needs to take the Project_Name and concatenate it with the Fab_Number, so the document library has a subfolder name 88Ridge_Fab2 and the attachments are copied there, then it needs to read the next one and make a subfolder called "88Ridge Redriver_Fab1" and copy its attachments there, etc...  In the end I am trying to have all the attachments in the doc library and the list should just have the details.  

 

Currently, I am stuck regarding how to create the subfolder name from the field in the list.  "Project Storage Library"  is the document library.

ErikH63_2-1616122403920.png

I am not bound to this idea so if there is a better way.

 

     Thanks for any help

         

 

1 ACCEPTED SOLUTION

Accepted Solutions
DamoBird365
Community Champion
Community Champion

Hi @ErikH63 

 

I think you need to play and understand what you have built.  An apply to each will run sequentially, i.e. one at a time.  If you have 100 sets of grouped actions in that loop and they take 6 seconds each, it will take ~600 seconds to complete i.e. 10 minutes.  You can explore concurrency, elipses top right of the apply to each and run up to 50 of these actions in parallel.  This will speed up your flow but as always you need to test.

 

Using the "next failed" button you can identify where 1 of the 100 stages failed and then look to address that specific problem.  Once you have correctly identified and handle these, you can run it again.

 

When you deep dive and learn as fast as you are right now, I think you need to take a step back and reflect.  Can I now do this any better with what I have learned?  

 

I've probably answered your initial questions about creating a new folder by appending two column names, if you have any further questions about the whole process that you are building, I think it would be fair to mark a solution here and ask that another community member help you with the next stage of learning in another post.

 

Good luck with your developments!

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here

View solution in original post

22 REPLIES 22
DamoBird365
Community Champion
Community Champion

Hi @ErikH63 

 

I think you are looking for:

DamoBird365_0-1616135781929.png

 

You just need to insert the two dynamic fields for your folder names into the folder path and seperate with a /.

DamoBird365_2-1616136145212.png

(your dynamic values will need to be contructed as expressions as you are in an apply to each).

 

You can create these in the expression tab and select OK

items('Apply_to_each')?['Field Name'] e.g. items('Apply_to_each')?['Project_Name']

items('Apply_to_each')?['Fab_Number']

 

Let me know how you get on or if you need more help.

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien

 

annajhaveri
Super User
Super User

@ErikH63  you can use below expression for the subfolder name to be provided in Folder Path parameter.

Replace Title an ID with your column names, note these will be internal column names, to get internal column name do following:

Go to your List Settings, then click on the specific column, then look at the browser URL, take the name what appears after the Field=

E.g. http://test.sharepoint.com/sites/test/_layouts/15/FldEditEx.aspx?List=%7BA4E78CC7-F74F-4733-832A-099... is my URL when I click on Link field in List Settings, here my internal field name is Link.

Use below expression to get subfolder name

concat(triggerOutputs()?['body/Title'],'_',triggerOutputs()?['body/ID'])

 

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

Hi @annajhaveri 

 

Good spot on the folder name but hopefully with @ErikH63 using _ between field names (like a pro) she will have avoided any ascii strings in the field names e.g. _x0020_ for space.

 

As we are using an apply to each we have to construct an expression for the item value but what I find quite interesting is that you have used a concat and it's equally as possible to just supply the two values seperated by a _ in the folder path like so:

 

Capture.PNG

 

For my learning, is there an advantage/disadvantage of using a concat for the string vs the method I propose above or is this personal preference?

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here

 

Thank you very much for the reply Damien!    I tried this, but I am getting an error regarding the "Apply_to_each", I tried to look this expression up but can't find anything about 'Apply_to_each", maybe I am using it incorrectly?  I did mean 88Ridge_Fab3 but I think I like your idea better. 

 

ErikH63_4-1616137915824.png

Thanks,

   -Erik

DamoBird365
Community Champion
Community Champion

Hi @ErikH63 

 

You've renamed your apply to each vs my out of the box:

DamoBird365_0-1616138407527.png

 

So the trick here is to select your apply to each as a dynamic content (temporarily) and then highlight it with your mouse and ctrl+c to copy the hidden code.  You can then paste it into notepad/word and view the exact phrase for your apply to each name (a trick of the trade).

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here

DamoBird365
Community Champion
Community Champion

@ErikH63 

 

For example, if I rename my apply to each to the name you have given it, I get:

 

items('Apply_to_each:_item_in_the_list')?['Project_Name']

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here

 

 

@DamoBird365  i think both approaches are fine to use, i dont see any specific pros and cons, while i was writing my response i didnt see that you had already responded to this post, its was when i posted the response, i saw there is already a response to this post.

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

Thank you Anna!  The URL and Field idea was great.    It ran but only generated one un-named folder in the document library for the 257 items in the list, my first run was just to see if I could create the folders before moving the files.  Note, Title was the name of the column.  Here is my expression:  

concat(triggerOutputs()?['boby/Title'],'_',triggerOutputs()?['body/Fab_Number'])

 

ErikH63_0-1616139707390.png

This is the document library:

ErikH63_1-1616139798837.png

 

Thanks,

     -Erik

 

DamoBird365
Community Champion
Community Champion

Hi @ErikH63 

 

It's because you are in an apply to each... you have to use 

items('Apply_to_each:_item_in_the_list')?['Project_Name']

 

And you can use a concat or you can simply add the expressions with a _ in the field - both options work, it's personal preference.

 

Damien

Hello Damien,

 

Now I understand, I changed the loop back to "Apply to each" and reran it with the fields, at first it didn't work and that was because Project_Name was not the field title as  @annajhaveri helped me see, after that correction it ran, however, 2 issues popped up.  

 

  1. I really wanted to do the" / "option you showed (where the Fab_Number is a subdirectory) instead of the "_" I had, but it seems it did not work that way it just created the Title (Project_Name) but no subdirectory (Fab_Number). Maybe it is due to issue #2, but I would have thought that the subdirectory would be created at the same time. 
  2. It seems that the flow timed out and did not build all the directories, should be 257 but only see about 69 of them.  This was only building the directories I had not yet copied files, so I am worried it will crash much earlier when I copy the files.

Any ideas?

  

    Thanks again for all the help,

          -Erik

Update: It shows that the flow timed out but if I go to the history I see it is still running.  So let me wait until it is done

It finally failed and did not make all the folders here is the report:

ErikH63_0-1616183688887.png

One raw input note:

ErikH63_1-1616183722527.png

 

Thanks,

   -Erik

 

DamoBird365
Community Champion
Community Champion

Hey there. I would guess you have invalid characters in your folder paths. Take a look here https://support.microsoft.com/en-us/office/invalid-file-names-and-file-types-in-onedrive-and-sharepo... Damien

I am going through all of them to remove invalid characters and I noticed that once person used the same title name but different fab numbers will the flow choke when it tries to create a title that it already created?  I need it to create the title folder and then make all the subfolders.  For example:

 

ErikH63_0-1616186976351.png

I need one Springhill M_2 folder and then all the fab* subfolders.

I removed all the invalid characters, and it failed again but not with the invalid character error. 

 

ErikH63_0-1616211069117.png

Here is what I am trying to do.  Since there are several Titles the same with different fab numbers I am trying to create the title folder and then add any fab number as a subfolder.  "Project_Storage" is the list and "Project Storage Library" is the document library I am trying to copy this to.  In the table below A21 Bird Key has the same title twice and 2 fabs.

 

ErikH63_1-1616211206916.png

 

Thanks for any help!

    -Erik

 

DamoBird365
Community Champion
Community Champion

Morning @ErikH63 

 

A steep learning curve for you.  This time you are calling a folder that doesn't exist with the list folder action.

 

I can create the same by calling a folder that I know does not exist

DamoBird365_0-1616221899329.png

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here

 

Thanks Damien, yes very step and painful.   I am confused as to where I am calling a folder that does not exist,  I do create a folder in a previous step that I then see if it has anything in it, can I not do that?  I am doing this in the event the folder already existed from a previous pass.   

DamoBird365
Community Champion
Community Champion

Hi @ErikH63 

 

I think I can see your problem now... maybe?!  

DamoBird365_0-1616224843985.png

 The path for the folder you have created must also include the document library.  So you will need to concat the doc lib to your newly created path in order to list the files in that folder.

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here

Thank you so much for helping!  

 

If so I am confused, do you mean the "Shared Documents" part?  Alothough it is not part of the URL: sharepoint.com/sites/jdp/Project%20Storage%20Library/Forms/AllItems.aspx

 

The other confusing part is that it does run for about 45min, before failing, and creates most of the Title (i.e., Project_Name) folders, but not all of them, however it does not create any of the subfolders i.e. Fab#. 

 

For grins, I removed the subfolder creation to see if it would make all the Title folders, but it fails after 43 min with 

ErikH63_0-1616225685655.png

Thanks,

    -Erik

Helpful resources

Announcements
MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Users online (38,336)