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 / 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,402 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

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 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard