web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Index'0' is out of range.
Power Automate
Answered

Index'0' is out of range.

(0) ShareShare
ReportReport
Posted on by 14
 
It seems that there are some mistakes in this workflow, anyone could help to see where the mistake may be.
 
 
 
Categories:
I have the same question (0)
  • Verified answer
    eetuRobo Profile Picture
    4,220 Super User 2025 Season 2 on at
    Error happens because the FoldersWithDates is actually empty and does not have item index 0.


    Your If condition is also wrong. You have "Length of %FoldersWithDates%" > 0 which is always true since it will check if the text "Lenght of % + variable is more than 0.

    For example: 


    That will always be true since "test test" is longer than 0 always. 

    So remove the 'Length of ' text from the If condition and have it check %FoldersWithDate.Count%
     

    Like so:


    Also is there a reason you are using PowerShell script? The CurrentItem should have .LastModified property to check the last modified time.
    So you could do like this to delete only the oldest folder in the AllItems folder path:


    Also you could already have the "Get subfolders in folder" to sort the folders by "Last modified" time. So then the AllItems will have the folder list from oldest to newest. 


    Then since that sorts the folder list from oldest to newest then the oldest folder is at the top of AllItems -list. Then you can just delete the first item in that folder list:

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 519 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 296 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard