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 / Problem using "FindTex...
Power Automate
Unanswered

Problem using "FindTextPosition" and LastSplit

(0) ShareShare
ReportReport
Posted on by 8

Hello,

 

I want to parse a specific text from my email body so I want to know the position of it in order to parse the text based on the position number so I'm using this code

 

last(split(outputs('HTML_To_Text')[outputs('Find_Text_Position').body],': '))

 

but I'm getting this error => The template language expression 'last(split(outputs('Html_to_text')[outputs('Find_Text_Position').body],': '))' cannot be evaluated because property '628' cannot be selected. Object properties can only be selected by names. Please see https://aka.ms/logicexpressions for usage details.'

 

I have attached  a screenshot of my flow

Screenshot_134.png
Categories:
I have the same question (0)
  • grantjenkins Profile Picture
    11,063 Moderator on at

    Are you able to show a sample of an email you get where you want to extract the data from, and what exactly you're trying to extract? There's potentially an easier way to extract your data.

     

    At the moment your expression is trying to pass in an index for Html to text, but it's not an array which is why you're getting the error.

  • grantjenkins Profile Picture
    11,063 Moderator on at

    Here's a quick example that extracts the Name and Amount from the body of my email.

     

    The email content is below.

    grantjenkins_0-1673597520171.png

     

    Full flow below. I'll go into each of the actions.

    grantjenkins_1-1673597574524.png

     

    Html to text takes in the Body from my email.

    grantjenkins_3-1673597641894.png

     

    This gives us data with a new line character at the end of each row.

    grantjenkins_4-1673597703047.png

     

    grantjenkins_5-1673597724590.png

     

    Filter array Name and Filter array Amount extract the row that starts with 'Name:' and 'Amount:' respectively. Below are the expressions used.

    //Used in both Filter arrays (Splits the data by new line)
    split(outputs('Html_to_text')?['body'], decodeUriComponent('%0A'))
    
    //Used in both Filter arrays as part of the condition
    item()

    grantjenkins_6-1673597862084.png

     

    This would give us the following outputs. A single item in an array.

    grantjenkins_7-1673597917209.png

    grantjenkins_8-1673597934778.png

     

    We then use the following expressions to extract out just the value part after the colon.

    //Name
    trim(last(split(first(body('Filter_array_Name')), ':')))
    
    //Amount
    trim(last(split(first(body('Filter_array_Amount')), ':')))

    grantjenkins_9-1673598058988.png

     

    Effectively it gets the first item in the Filter array, splits it by colon, retrieves the last item from the split, then trims any white space. The results are:

     

    grantjenkins_10-1673598092314.png


    ----------------------------------------------------------------------
    If I've answered your question, please mark the post as Solved.
    If you like my response, please consider giving it a Thumbs Up.

  • NourR Profile Picture
    8 on at

    Thank you so much for your answer and for showing the example. Unfortunately my e-mail is too big and a lot of things needs to be extracted and every time the positioning of the texts gets moved.  In my opinion the only fastest is to find the exact position of the text in mail.

     

    I tried instead of finding the position of the HTMLToText to find it in the SplitBodyText but I also get an error.

     

    This is the tutorial I'm following => https://www.youtube.com/watch?v=62BB3rpe37g&t=324s and It works well with me until step number 5 (in the video you can start from minute 5:21) but I want to include the output FindTextPosition in the code.

     

     

    PleaseScreenshot_135.png find also the attached picture

  • NourR Profile Picture
    8 on at

    Another question,

     

    I tried your example and it works very well but I have a question - What If i have 2 fields in the email that contains the same keyword? for example If I have 2 fields that containts "Amount" part, what can I do in this case?

  • grantjenkins Profile Picture
    11,063 Moderator on at

    I set the condition where it Starts with Name: (including the colon) - so we wouldn't have an issue if we had multiple instances where Name was included since we include the colon.

     

    Do all your cases have the property name as the start of the string, then a colon, then the value? Or do you have something different? It's difficult to see what would work best without seeing some of your email. Even a sample of the data would be good.

     

    The video you shared will only work if the properties/values come through in the same location/order, so not ideal.

  • NourR Profile Picture
    8 on at

    Thanks for your quick response.

     

    Please find an example of the email in this link => https://pastebin.com/yBwa8cvi

     

    Some of the duplicated fields that i would like to extract is "ON:" as you can see I have 2 dates & 2 timing

     

    The first way journey date & time and the return journey date & time

     

    How can I parse them both If they both have the same text field?

     

    I want to

    1. On: Friday, April 14 2023
    2. On: Saturday, April 22 2023

     

    How can I parse them both and they both have the same field?

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 873

#2
Valantis Profile Picture

Valantis 813

#3
Haque Profile Picture

Haque 526

Last 30 days Overall leaderboard