Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows

The length of substring can't be longer than '8' which is the length of the source string.

(0) ShareShare
ReportReport
Posted on by
 
 
     
 
 
Detailed flow steps
 
 
 
substring(outputs('Compose_Replace_NewLine'),0,outputs('Compose_Index_of_Thanks'))
 
indexOf(outputs('Compose_Replace_NewLine'),'Thanks')
replace(outputs('Compose_Email_Body'),outputs('Compose_NewLine'),'')
 
 
 
 
 
 
 
 
 
 
Im need to extract body from the email and create item in body column under sharepoint list but issue im running the flow is that  
 
InvalidTemplate. The length of substring can't be longer than '8' which is the length of the source string.
 
 
 
 
 
 
 
  • blitz Profile Picture
    on at
    The length of substring can't be longer than '8' which is the length of the source string.
    Im facing the same issue and this time error is InvalidTemplate. The length of substring can't be longer than '4' which is the length of the source string.
     
    I used below expression for the below scenarios
    substring(outputs('Html_to_text')?['body'],0,indexOf(outputs('Html_to_text')?['body'],'Thanks'))
     
    This my email sample screenshot
     
    Scenarios email sample
     
    Email Sample 1: 
     
     
    Email Sample 2: when i use the below expression,in this scenario its only create  Hi,welcome text values and below values were removed as per this expression
     
     
    substring(outputs('Html_to_text')?['body'],0,indexOf(outputs('Html_to_text')?['body'],'Thanks'))
     
    Output:
     
    Sharepoint list
     
    Title     Body 
               Hi,Welcome
     
    Overall, my ask is that when create item in sharepoint list we should create body value by removing unncessary blank lines and email signatures images as its creating unreadable text values  while flow parsing. 
  • Nived_Nambiar Profile Picture
    17,778 Super User 2025 Season 1 on at
    The length of substring can't be longer than '8' which is the length of the source string.
    @Expiscornovus has explained why the scenario is happening. To handle we may need to re-write the expression. For example and easy to develop the expression- could you please share the what is input text and how it should be expected.
     
     
    i have developed a sample which extracts the data from the email. see below, Not sure whether this fits your case/scenario.
     
    I have used an email with format like this
     
     
    Now coming to flow, I have developed for extracting email body data just before Thanks word
     
     
    Expression used - 
    substring(outputs('Html_to_text')?['body'],0,indexOf(outputs('Html_to_text')?['body'],'Thanks'))
     
    This gives me an output like this-
     
    Well you can include the replace expression to replace new line something like below by modifying above expression
     
    replace(substring(outputs('Html_to_text')?['body'],0,indexOf(outputs('Html_to_text')?['body'],'Thanks')),decodeUriComponent('%0A'),'')
     
     
    Thanks & Regards,

    Nived N :rocket:

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel
    Blog: Nived Nambiar's Blogs

    :magnifying_glass_tilted_left: Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! :raising_hands:

     
  • blitz Profile Picture
    on at
    The length of substring can't be longer than '8' which is the length of the source string.
    Kindly help me how to modify below expression as per your reference 
     
  • Expiscornovus Profile Picture
    31,889 Most Valuable Professional on at
    The length of substring can't be longer than '8' which is the length of the source string.
    I see you are using this expression with the substring function
    substring(outputs('Compose_Replace_NewLine'),0,outputs('Compose_Index_of_Thanks'))
    In this example the outputs Compose_Replace_NewLine has length of 8. However, the error message suggests that outputs of Compose_Index_of_Thanks is longer than 8. A substring function is not able to handle that and would give you an error in that situation.
     
    For reference also see the docs: https://aka.ms/logicexpressions#substring
    Make sure that the sum from adding the startIndex and length parameter values is less than the length of the string that you provide for the text parameter. Otherwise, you get an error, unlike similar functions in other languages where the result is the substring from the startIndex to the end of the string. The length parameter is optional and if not provided, the substring() function takes all the characters beginning from startIndex to the end of the string.

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