Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Unanswered

Best way to get around an array error Out of Bounds

(0) ShareShare
ReportReport
Posted on by 83
I have a flow that works most of the time.  When the email subject line has 4 array items, it runs no issue.  But I do have some subject lines that are shorter and that's when the flow fails.
 
Looking for a better work around so that the flow will ignore CustName4 variable and output later in my flow if it's null, blank, outside the bounds (0,3) of array, etc.
 
I have several splits setup to pull out just the pieces I need from the Subject Line and I have a filter on the trigger also.
 
Happy to try to show my workflow if that helps.
 
Any thoughts or work arounds would be greatly appreciated.
 
Here's the error message I get and the Code view.
 
InvalidTemplate
Unable to process template language expressions in action 'CustName4' inputs at line '0' and column '0': 'The template language expression 'outputs('Further_Split_for_customer_num_Name')[4]' cannot be evaluated because array index '4' is outside bounds (0, 3) of array. Please see https://aka.ms/logicexpressions for usage details.'.
 
 
Code View:
{
  "type": "InitializeVariable",
  "inputs": {
    "variables": [
      {
        "name": "CustName4",
        "type": "string",
        "value": "@{outputs('Further_Split_for_customer_num_Name')[4]}"
      }
    ]
  },
  "runAfter": {
    "CustNme3": [
      "Succeeded",
      "TimedOut",
      "Skipped",
      "Failed"
    ]
  },
  "metadata": {
    "operationMetadataId": "2b22ddea-ff75-4496-b8e5-8352c9bcdf05"
  }
}
  • ktownshend Profile Picture
    83 on at
    Best way to get around an array error Out of Bounds
    The flow starts from a mailbox that holds emails that come in with the subject line of:
    13682 US Foods - Boston Seabro Cultur Pricing Oct 2024 or similar wording
     
    I split the subject line on the space to break it down: 
    split(outputs('Email_Subject_as_Text'), ' ')
     
    I then split that further to pull out what I don't need
    split(outputs('Email_Subject_as_Text'), 'Cultur Pricing')
     
    Then i grab the [0] of the array 
    variables('Split on Cultur Pricing')[0]
     
    So I can break that out by the space
    split(outputs('Split_to_Customer_num_name'), ' ')
     
    This gets me the Customer Number and then 3 to 4 pieces for the Customer Name.
     
    Where I'm having the issue is if [4] is outside of the bound for the split,
    it's tossing me the error.
     
    How would I effectively use Length in my coding to adapt for this issue?
     
    Screenshots of flow below.
     
  • CFernandes Profile Picture
    8,295 Most Valuable Professional on at
    Best way to get around an array error Out of Bounds
    Can you share the screenshot of your Power Automate? One option would be get the Length(which returns a number) and then build a logic. on top of it using a condition or a switch
     
    length(outputs('Get_items')?['body/value'])

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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 566 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 516 Super User 2025 Season 1

#3
stampcoin Profile Picture

stampcoin 492