cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
User_2ja7Dhh89
Frequent Visitor

Copying folder structure AND renaming the new root folder using dynamic content?

Hello,

 

Hoping someone can help me, as I've read numerous posts on this but still struggling as I'm very new to Power Automate.

 

The closest solution I have found is this one, but due to my lack of experience in that area, I cannot get it to work for my site because I don't fully understand how it works.

 

What I am trying to set up

A flow which:

1. Automatically duplicates a default folder structure in a document library, structure is:

  • Folder A
    • Sub-Folder B
      • File A (excel file, always standard)
    • Sub-Folder C
    • Sub-Folder D
    • Sub-Folder E

2. Automatically renames the newly created Folder A based on one of the values in the latest addition of a list item

 

Where I have got to so far

I have created a simple flow which achieves point 1. above (can't seem to paste screenshots, so will describe below):

- When an item is created: [site address]: [list name]

- Copy Folder: [current site address]: [folder to copy] (this is a folder structure within a document library): [destination site address]: [destination folder] (a different document library): [fail this action]

 

The list imports data from MS forms. One of the columns in the list contains data which is to be used to rename Folder A in the newly duplicated folder structure.

My question is, how do I set this up dynamically so that each time the new folder structure is created, Folder A automatically gets renamed using the data in Column X of the list. Is this possible?

 

Any help appreciated, many thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
v-litu-msft
Community Support
Community Support

Hi @User_2ja7Dhh89,

 

Yes, you could use the column value get from the MS Form to update the new created Folder, instead of Update file properties action, you should use the Send an HTTP request to SharePoint action to update the folder name:

Method: Post

URI: _api/web/GetFolderByServerRelativeUrl('Hub/@{body('Copy_folder')?['DisplayName']}')/ListItemAllFields

Headers:  "Accept""application/json;odata=verbose",

                "X-HTTP-Method""MERGE",
                "If-Match""*"

Body:  {
            'Title': 'NewFolderName',
            'FileLeafRef': 'NewFolderName'
           }

Annotation 2020-05-15 105633.jpg

 

Best Regards,
Community Support Team _ Lin Tu
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

6 REPLIES 6
v-litu-msft
Community Support
Community Support

Hi @User_2ja7Dhh89,

 

Yes, you could use the column value get from the MS Form to update the new created Folder, instead of Update file properties action, you should use the Send an HTTP request to SharePoint action to update the folder name:

Method: Post

URI: _api/web/GetFolderByServerRelativeUrl('Hub/@{body('Copy_folder')?['DisplayName']}')/ListItemAllFields

Headers:  "Accept""application/json;odata=verbose",

                "X-HTTP-Method""MERGE",
                "If-Match""*"

Body:  {
            'Title': 'NewFolderName',
            'FileLeafRef': 'NewFolderName'
           }

Annotation 2020-05-15 105633.jpg

 

Best Regards,
Community Support Team _ Lin Tu
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

Hi there @v-litu-msft ,

 

Thanks so much for the reply. It's really useful and has gotten me further than before!

 

However, the flow still gets stuck and says '1 retry' on the 'Send an HTTP request for SharePoint' part. When I click view, it looks as though everything is fine (it's even picked up the dynamic content from my List as to the folder name), but for some reason it doesn't complete the action, and the folder name does not change.

 

I have a feeling it's something to do with what I have written in the body? In your example I see you have used expressions. For mine, I just put the dynamic content of the relevant field in the SharePoint List here. Am I doing something wrong? Everything else is exactly as you have written it.

 

Many thanks again.

Hi @User_2ja7Dhh89,

 

Actually, the expression is a kind of dynamic content, too. So the root of the reason not the expressions. You could even input a fixed value into the Body to rename the folder.

 

Could you please check the connection of the Send an HTTP request action?

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Hi @v-litu-msft,

 

Thanks.

 

Please could you just explain to me how to check the connection? When I click settings on the action, it shows My connections and my e-mail address associated with my O365 account, which is where I am building the flow so I think that is correct.

 

Maybe I need to somehow connect to the SharePoint site? Although I would have thought that happens in the 'Site Address' field.

 

By the way: the status says 'Bad Gateway', so I'm wondering if the request is being sent over the SharePoint site, it must need a permission somewhere if it's being blocked?

Hi @User_2ja7Dhh89,

 

You could check the connection whether valid when you test it, click the Review connections and actions, if they are green mark, it is valid:

Annotation 2020-05-22 160654.jpg

 

Annotation 2020-05-22 160840.jpg

 

Annotation 2020-05-22 160859.jpg

 

If you assume it is a permission issue, you could confirm you whether have edit permission:

https://support.office.com/en-us/article/customize-permissions-for-a-sharepoint-list-or-library-02d7...

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-litu-msft 

 

Hi there, Unfortunately I still cannot get this to work. I have reviewed the connection; it is fine and has a green tick. I am also an Owner of the site, so no permissions problems there.

 

The error messages changes each time. Sometimes it runs and just times out (and doesn't rename the folder). Sometimes it says 'Cannot read property 'properties' of undefined' but doesn't show where to edit the flow.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Users online (1,490)