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 / InvalidTemplate. The l...
Power Automate
Answered

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

(0) ShareShare
ReportReport
Posted on by 82

Hi,

 

I am developing a flow to convert email body from HTML into text. However, I've come across this error where it said it had exceeded the substring length limit. I do set the limit in the next step in "Compose 7" with 5000 characters. If I were to fix this issue, do I have to move it above or is there any extra steps I should add to it? Here I attached with my flow and the text error result. 

 

Thank you.  

Flow Sequence: 

Xinlin_2-1670571322600.png

Xinlin_3-1670571347888.png

 

             

 

Flow Error Details: 

Xinlin_0-1670571198998.png

Xinlin_1-1670571229457.png

 

Categories:
I have the same question (0)
  • v-dezhili-msft Profile Picture
    Microsoft Employee on at

    Hi @Xinlin ,

     

    The third parameter of substring() has the following restrictions.

    vdezhilimsft_1-1670578756239.png

     


    Your string length is only 3296, you can change your function to

    substring(outputs("Compose_6"),0,3296)

     flow will run successfully.
    But this will output all the characters of Compose_6 and there is no difference between referencing Compose_6 directly.
    Could you please tell me your purpose of using substring()?

     

    Best Regards,

    Dezhi

  • Expiscornovus Profile Picture
    33,937 Most Valuable Professional on at

    Hi @Xinlin,

     

    I believe the calculation of the length in Compose 6 of this example is sub(-1,8). The outcome of that is -9, a negative number.

     

    Which is not allowed as a length parameter in a substring function. That needs to be a positive number.

  • Xinlin Profile Picture
    82 on at

    My flow got stuck at the 'Compose 6' stage which I think it will likely run into the same issue again even if I change it to 

    substring(outputs("Compose_6"),0,3296)

    The purpose of this flow was to read body of incoming email and capture the text into an AI Model that I've built for text classification. Hence needed to convert email into text first. 

     

  • Xinlin Profile Picture
    82 on at

    I see, do you mind sharing the possible solution i could look for to fix this issue? 

  • v-dezhili-msft Profile Picture
    Microsoft Employee on at

    Hi @Xinlin ,

     

    Sorry for my mistake.
    From the output, it seems that there is no "Start time" string in your email body.

    vdezhilimsft_0-1670580384768.png

     

    Best Regards,

    Dezhi

     

  • Verified answer
    Expiscornovus Profile Picture
    33,937 Most Valuable Professional on at

    Hi @Xinlin,

     

    Try this instead in the Compose 6

    if(equals(outputs('Compose_5'), -1), 'Start Time not found', substring(outputs('Html_to_text')?['body'], outputs('Compose_4'),sub(outputs('Compose_5'),outputs('Compose_4'))))
  • Xinlin Profile Picture
    82 on at

    I changed 'Start time not found' to the html to text output and it works, thank you so much!

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 238 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 225

#3
Haque Profile Picture

Haque 181

Last 30 days Overall leaderboard