Skip to main content

Notifications

Power Automate - Using Flows
Unanswered

Flow is getting failed-path for the new folder is not valid

(0) ShareShare
ReportReport
Posted on by 2,185

I have uploaded the below excel in sharepoint document library in order to power automate to create folder structure

 

Veblitz_0-1719651099069.png

 

Please note i need to create above excel details in the nested folder  into my sharepoint document library

 

Flow steps

 

Veblitz_1-1719651156186.png

Expanding Applyto each step

Veblitz_0-1719652151976.png

 

Veblitz_2-1719651596185.png

Veblitz_3-1719651662589.png

 

Expanding Apply to each step

 

Veblitz_4-1719651760089.png

Veblitz_5-1719651849366.png

 

 

 

  • NathanAlvares24 Profile Picture
    NathanAlvares24 1,673 on at
    Re: Flow is getting failed-path for the new folder is not valid

    Hi @Veblitz !

     

    Please see below flow of mine. I replicated same and it works. I'll explain it on the way with every screenshot for you to understand.

     

    Flow:

    Pic 1

    NathanAlvares24_0-1719689604401.png

     

    Pic 2

    NathanAlvares24_1-1719689664878.png

     

    Pic 3

    NathanAlvares24_2-1719689805674.png

     

    Let me explain now:

    I guess till list rows is already understood.

    NathanAlvares24_3-1719689885326.png

    I added these two actions because of the case where you have all columns empty in a row based on your data from excel:

    NathanAlvares24_4-1719689990913.png

     

    This will help to filter the rows based on an expression:

     

    @or(not(equals(trim(item()?['Month']), '')), not(equals(trim(item()?['Country']), '')), not(equals(trim(item()?['Customer']), '')), not(equals(trim(item()?['New']), '')))

     

    Please ignore the warning above this action after inserting this action and going back to basic mode. It will work for sure.

    NathanAlvares24_5-1719690049437.png

    So example output will be for this:

    NathanAlvares24_6-1719690137229.png

     

    And its just what you need. Use this body in the output of apply to each action.

    NathanAlvares24_7-1719690242328.png

     

    The condition 5 (change the name as you want. I just kept it as the same) is really important. This is the year folder.

     

    2024
    │
    ├── 1
    │ └── USA
    │ └── Microsoft
    │ └── Renewal
    │
    ├── 2
    │ └── UK
    │ └── ABC
    │ └── Pending
    │
    └── 3
     └── [Country Not Specified]
     └── Cool
     └── Approvals
    
    You gave me this right? Now see in the case of this:
    └── 3
     └── [Country Not Specified]
     └── Cool
     └── Approvals

     

    You know based on above, the year folder serves as a parent folder to the rest as the year column for the other two rows are empty. This is what the condition does. Store this year folder name in a variable and use it throughout till it encounters another year in that column of which it will overwrite the previous year.

     

    Now I will give expressions for each condition and its yes and no parts:

    1) Condition 5

    NathanAlvares24_8-1719690611512.png

    Expressions used:

     

    (type these in the expression tab)
    
    Condition 5:
    not(equals(items('Apply_to_each')?['Year'],''))
    true (type this in the expression tab)
    
    directly paste the following in the "Folder Path" section:
    
    Create new folder 5:
    @{items('Apply_to_each')?['Year']}

     

     

    2) Condition

    NathanAlvares24_9-1719690835652.png

    Expressions used:

     

    (type these in the expression tab)
    
    Condition:
    not(empty(items('Apply_to_each')?['Month']))
    true (type this in the expression tab)
    
    directly paste the following in the "Folder Path" section:
    
    Create new folder 4:
    @{variables('Year')}/@{items('Apply_to_each')?['Month']}

     

     

    3) Condition 2

     

    NathanAlvares24_10-1719691082839.png

    Expressions used:

     

    (type these in the expression tab)
    
    Condition 2:
    not(empty(items('Apply_to_each')?['Country']))
    true (type this in the expression tab)
    
    directly paste the following in the "Folder Path" section:
    
    Create new folder 3:
    @{variables('Year')}/@{items('Apply_to_each')?['Month']}/@{items('Apply_to_each')?['Country']}

     

     

    4) Condition 3

    NathanAlvares24_11-1719691199090.png

    Expressions used:

     

    (type these in the expression tab)
    
    Condition 3:
    not(empty(items('Apply_to_each')?['Customer']))
    true (type this in the expression tab)
    
    directly paste the following in the "Folder Path" section:
    
    Create new folder 2:
    @{variables('Year')}/@{items('Apply_to_each')?['Month']}/@{items('Apply_to_each')?['Country']}/@{items('Apply_to_each')?['Customer']}

     

     

    5) Condition 4

    NathanAlvares24_12-1719691253232.png

    Expressions used:

     

    (type these in the expression tab)
    
    Condition 4:
    not(empty(items('Apply_to_each')?['New']))
    true (type this in the expression tab)
    
    directly paste the following in the "Folder Path" section:
    
    Create new folder:
    @{variables('Year')}/@{items('Apply_to_each')?['Month']}/@{items('Apply_to_each')?['Country']}/@{items('Apply_to_each')?['Customer']}/@{items('Apply_to_each')?['Name']}

     

     

    Input:

    NathanAlvares24_16-1719692036414.png

     

    Output:

     

    NathanAlvares24_15-1719691567390.png

     

    In 2022:

    NathanAlvares24_20-1719692162201.png

    NathanAlvares24_17-1719692061053.png

     

    In 2023:

    NathanAlvares24_21-1719692171331.png

    NathanAlvares24_18-1719692079960.png

    The other one of 2023 has Month column empty hence won't create the folders for the subsequent data.

     

    In 2024:

    NathanAlvares24_19-1719692145546.png

    NathanAlvares24_22-1719692187497.png

     

    NathanAlvares24_23-1719692198581.png

     

    NathanAlvares24_24-1719692213197.png

     

    This flow will surely guarantee you 100% success in creating the folders.

     

    I hope this helps. Please do let me know once tried.

  • Veblitz Profile Picture
    Veblitz 2,185 on at
    Re: Flow is getting failed-path for the new folder is not valid

    Yes correct.

     

    I just removed apply to each and with one loop i managed to create nested folders and it looks alright but not sure if work for more sub folders .

     

    Thanks for your continuous inputs and it helped me to learn issues and able to resolve errors 

  • Veblitz Profile Picture
    Veblitz 2,185 on at
    Re: Flow is getting failed-path for the new folder is not valid

    My excel values are

    Veblitz_0-1719686407954.png

     

    Document library nested folder structure once flow ran output

     

    Veblitz_1-1719686457758.png

     

    when i click 2022 folder

    Veblitz_2-1719686494779.png

    when i click 2022/1 folder level

    Veblitz_3-1719686537094.png

    when i click 2022/1/uk folder level

     

    Veblitz_4-1719686604009.png

    Veblitz_5-1719686648654.png

    Veblitz_6-1719686687007.png

    Overall, if you see the excel values and the below one we are not sure y 1,2,3 month is getting created for the year 2022,2023,2024 since we don't have 3 subfolders in the each year

     

    Veblitz_8-1719686905416.png

     

    Veblitz_7-1719686746001.png

    Veblitz_9-1719686948722.png

     

     

     

     

     

     

     

  • Veblitz Profile Picture
    Veblitz 2,185 on at
    Re: Flow is getting failed-path for the new folder is not valid

    Yes i removed blank values but unfortunately we are able to get rid of error but folder structure is not getting created as expected.I am unable to create remaining 2 levels but no error and this time no blank spaces

     

  • Veblitz Profile Picture
    Veblitz 2,185 on at
    Re: Flow is getting failed-path for the new folder is not valid

    Thanks.

     

    It's creating year and month nested folders though if it's having blank spaces and after which it's getting failed

  • Veblitz Profile Picture
    Veblitz 2,185 on at
    Re: Flow is getting failed-path for the new folder is not valid

    Veblitz_0-1719674759206.png

     

    encodeUriComponent(concat(outputs('Create_new_folder')?['body/Title'],'/',items('Apply_to_each2')))

     

    Im getting error details as "path for the new folder is not provided"

  • Veblitz Profile Picture
    Veblitz 2,185 on at
    Re: Flow is getting failed-path for the new folder is not valid

    Thanks for the inputs

    I am able to create two levels such as year and month (2 levels) and the remaining levels were not getting created hence im getting such errors.

     

    Im not sure how to reference EncodeURIComponent() function with the above usecase.

    encodeUriComponent(variables('Uri'))// what value we may need to reference 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,666

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,996

Leaderboard

Featured topics

Restore a deleted flow