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 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.
 
 
 
 
 
 
 
I have the same question (0)
  • Expiscornovus Profile Picture
    33,195 Most Valuable Professional on at
    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.
  • blitz Profile Picture
    on at
    Kindly help me how to modify below expression as per your reference 
     
  • Nived_Nambiar Profile Picture
    18,129 Super User 2025 Season 2 on at
    @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
    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. 

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

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard

Featured topics