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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Best way to get around...
Power Automate
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"
  }
}
Categories:
I have the same question (0)
  • CFernandes Profile Picture
    8,504 Most Valuable Professional on at
    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'])
  • ktownshend Profile Picture
    83 on at
    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.
     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 262 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 167

#3
Haque Profile Picture

Haque 154

Last 30 days Overall leaderboard