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 / Error Action 'Compose_...
Power Automate
Suggested Answer

Error Action 'Compose_title' failed

(2) ShareShare
ReportReport
Posted on by
Encountered the error with composite title as below:
InvalidTemplate. The 'start index' for function 'substring' must be equal to or greater than zero and must be less than '42' which is the length of the string.https://aka.ms/logicexpressions#substring
 
Appricated if anyone may help.  
title_error.JPG

Your file is currently under scan for potential threats. Please wait while we review it for any viruses or malicious content.

Categories:
I have the same question (0)
  • Suggested answer
    eetuRobo Profile Picture
    4,565 Super User 2026 Season 1 on at
    Sounds like your Substrings Count has larger value than the string has characters in it.
    So the last parameter: SUBSTRING([string],[start],[count])

    https://learn.microsoft.com/en-us/power-automate/minit/string-operations#substringstringstartcount

    Try changing the count to be less than 42 so for example five:
    substring(outputs('YourStringAction'), 1, 5)
    Example of a flow with substring in use
    result:
  • Kalathiya Profile Picture
    2,456 Super User 2026 Season 1 on at
     
    Substring() expression is trying to start at an invalid position in the string. In many cases, How you are calculating Start Index? Sometime if Start index is greater than string or less than one means negative then this type of error will occure. 
     

    Could you share the substring() expression you're using and a sample of the composite title value? That would help identify the exact cause and suggest the correct fix.

    ---------------------------------------------------------------------------
    Glad it helped 🙂
    If this fixed your issue,
    please click “Does this answer your question?” to mark it as verified so others can find the solution easily.
    A Like 👍 is always appreciated, and I’m around if you need more help @Kalathiya
  • Suggested answer
    11manish Profile Picture
    3,333 on at
    The issue is not with the Composite Title itself but with the substring() expression that is processing it. One or more records likely contain a title format that differs from what the flow expects, causing the calculated start position to be either -1 or greater than the string length. Review the substring() expression, check any indexOf() functions used to calculate the start position, and add validation to ensure the start index is within the valid range before calling substring(). If you can share the exact expression, it will be possible to identify the precise fix.
  • Suggested answer
    Valantis Profile Picture
    6,735 on at
     
    The error tells you exactly what's wrong: the start index passed to substring() is negative or exceeds 42, which is the length of the string in that specific run.
     
    This happens when indexOf() returns -1 (meaning the search character wasn't found) and you add to it without checking first.
     
    For example, if your expression is something like:
    substring(body, add(indexOf(body, '-'), 1), 10)
    And the title has no '-' character, indexOf returns -1, and substring tries to start at position 0 or negative, which throws this error.
     
    The safe pattern is to check before using the result:
    if(greater(indexOf(body('Compose_title'), '-'), -1), substring(body('Compose_title'), add(indexOf(body('Compose_title'), '-'), 1), 10), body('Compose_title'))
    This returns the original string if the separator isn't found, instead of erroring.
     
    Could you share the exact expression inside your Compose_title action? That will let us give you the precise fix rather than a general pattern.
     

     

    Best regards,

    Valantis

     

    ✅ If this helped solve your issue, please Accept as Solution so others can find it quickly.

    ❤️ If it didn’t fully solve it but was still useful, please click “Yes” on “Was this reply helpful?” or leave a Like :).

    🏷️ For follow-ups  @Valantis.

    📝 https://valantisond365.com/

    💼 LinkedIn

    ▶️ YouTube

  • Suggested answer
    Haque Profile Picture
    3,653 on at
    Hi @CU07010322-0,
     
    Mostly covered all corner areas, just a safety check:
     
    We can use indexOf() to check if result is -1, if so handle that case.
    We can make sure start index is never negative using max(0, index) 
    We can make sure it doesn't exceed string length using min(index, length(string) - 1)
     
     

    I am sure some clues I tried to give. If these clues help to resolve the issue brought you by here, please don't forget to check the box Does this answer your question? At the same time, I am pretty sure you have liked the response!

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 377

#2
11manish Profile Picture

11manish 279

#3
David_MA Profile Picture

David_MA 234 Super User 2026 Season 1

Last 30 days Overall leaderboard