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 / Split email subject li...
Power Automate
Unanswered

Split email subject line to get certain pieces with an array

(0) ShareShare
ReportReport
Posted on by 83
I'm looking for an assist on how to script my split() function to accommodate for subject lines that can have as few as 5 items and as many as 10 once I create the array.
 
I'm using the subject lines to populate a SharePoint list. 
I need to pull out from the subject line the Customer#, Name and Month Year.
 
Samples:
13919 Woolco Foods Cultured Ac Cultur Pricing Oct 2024
12890 Sysco F/S Halfmoon NY Cu Cultur Pricing Aug 2017
540/0 Rest Depot Metro NY Regi Cultur Pricing Sep 2024
14540 Baldor Boston, LLC Cultur Pricing Aug 2023
 
Scripts:
Array script: split(outputs('The_string'), ' ') - the string is the subject line from the email
Customer Number script: outputs('the_split')[0] (This needs to be able to capture the #/#)
Month script: trim(last(split(variables('text'), 'pricing'))) (This gets me both month and year, need to get just month and then just year, I'm having a hard time getting it to just get me the single piece, I know I'm missing something probably so simple to complete the script)
RED, not needed but is part of the array and is counted as such
Blue is the report name and is being hard coded as it will always be the same for all records
 
Array Sample:
[
  "13919",
  "Woolco",
  "Foods",
  "Cultured",
  "Ac",
  "Cultur",
  "Pricing",
  "Oct",
  "2024"
]
 
Errors if more than or less than: (subject lines can have 6 to 10 items)
The error in the flow occurred because the expression 'outputs('the_split')[9]' is trying to access an index that is outside the bounds of the array (0, 8).  (Compose 9 and 10 probably need a skip if null but I'm not finding the right combination of scripts to make that work.)
 
I'm so close on my own but need that last tweak to get it perfect. Any thoughts and help are greatly appreciated.
 
 
 
Categories:
I have the same question (0)
  • creativeopinion Profile Picture
    10,502 Super User 2025 Season 2 on at
    You need to adjust the logic in your flow. Relying on a single split() function isn't ideal as the array will not output the same number of items each time.
     
    Refer to this section of my YT Tutorial linked below for more details on the split() function. Tip: Rename your compose actions to keep your flow organized. It will make it easier to identify which Compose action has what output.
     
    Compose – Split at Cultur Pricing
    You can split a string with another string. In this case you can split your subject line by ' Cultur Pricing' (include the space before). This will return an array that should look something like this:
    [
      "13919 Woolco Foods Cultured Ac",
      "Oct 2024"
    ]
     
    Important: You indicated that one of your subject lines included a Cu before Cultur Pricing. This can pose as an issue. You might need to add a condition to filter out those subject lines and adjust your expression. 
     
    Compose – Customer Number
    Use the first() function on the output of the Compose action above. Run a test. It should output the first item of the array. 
     
    Wrap the expression in the split() function and split that string with a space. Run a test. The output should look like this:
    [
      "13919",
      "Woolco",
      "Foods",
      "Cultured",
      "Ac"
    ]
     
    Click the expression to edit it. Since the customer number will always be the first item, use the first() expression. Wrap the expression in the first() function. Run a test. If you aren't clear on what wrapping an expression means—check out my tutorial linked below.
     
    Compose – Date
    The date is in the last item of the array (Compose – Split at Cultur Pricing). Use the last() function and insert the output from the Compose – Split at Cultur Pricing. Run a test. This should output the date.
     
    ----
     
    7 Functions You Need to Know | ⚡️Expression Essentials: Part 1⚡️
     
    In this section, I'll cover how to get dynamic content with an expression when the dynamic content you need isn't listed in the dynamic content menu.
     
    In the full tutorial I cover 7 functions you need to know when getting started with expressions.
    1️⃣ empty()
    2️⃣ coalesce()
    3️⃣ equals()
    4️⃣ if()
    5️⃣ concat()
    6️⃣ length()
    7️⃣ split()
     
    I cover how to use these functions in expressions and I’ll also cover common mistakes when it comes to writing expressions and show you a few tips and tricks along the way.
     
    As a beginner or even an intermediate flow builder—expressions can seem a bit complex at first, I’m going to try to simplify it for you. If you want to level up your flows by writing expressions—keep watching!
     
    IN THIS VIDEO:
    ✅ What is an Expression?
    ✅ What is a Function?
    ✅ What Does Wrapping a Function Mean?
    ✅ How Do I Insert an Expression?
    ✅ How to Use a Compose action
    ✅ How to Navigate the Expression Builder with Arrow Keys
    ✅ How to use the Expression Tooltip
    ✅ Common Mistakes When Writing Expressions
    ✅ How to differentiate a null from an empty string
    ✅ How to Get Dynamic Content When it’s Not Listed
    ✅ How to Use a Get Item Action to Verify Dynamic Content Output
    ✅ How to Convert Strings to Lower Case
    ✅ How to Troubleshoot the if() Function
     
    Hope this helps!
     
     
     
  • ktownshend Profile Picture
    83 on at
    @creativeopinion,
     
    Thank you for this information and I'm using it to work thru my issue.
     
    Is there a way to check for and move past any Null Arrays?
     
    Some of my subject lines are as short as 6 and as long as 10.  When trying to build this flow to capture everything I need, I'm running into errors if the subject line stops at 6, 7, 8, 9.  
     
    Should I use a condition and if null skip if not use type of thing?  What would that look like?
     
    I'm not good with IF statements so any help would be awesome.

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

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard