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/