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 Automate
Unanswered

Concat issues

(0) ShareShare
ReportReport
Posted on by 22
Hi All,
I'm having issues with concat placed with and email send v2.
 
This works: concat('<b>Gift 2: Alcohol Gift</b><br>',outputs('Home_Address')?['body/r6036d107afcb425faf8518eab85f348f'])
 
This works: if(equals(substring(outputs('Home_Address')?['body/r59ccb065f2e84f9dac89313e4c80ce66'], 0, indexof(outputs('Home_Address')?['body/r59ccb065f2e84f9dac89313e4c80ce66'],' - ')), 'Alcohol Gift'),concat('<b>Gift 2: Alcohol Gift</b><br>','ab'), '')
 
But this doesn't: if(equals(substring(outputs('Home_Address')?['body/r59ccb065f2e84f9dac89313e4c80ce66'], 0, indexof(outputs('Home_Address')?['body/r59ccb065f2e84f9dac89313e4c80ce66'],' - ')), 'Alcohol Gift'),concat('<b>Gift 2: Alcohol Gift</b><br>',outputs('Home_Address')?['body/r6036d107afcb425faf8518eab85f348f']), '')
 
Any ideas why when I run a test on the flow I get the error: 
Action 'Send_an_email_(V2)' failed: Unable to process template language expressions in action 'Send_an_email_(V2)' inputs at line '0' and column '0': 'The template language function 'substring' parameters are out of range: 'start index' and 'length' must be non-negative integers and their sum must be no larger than the length of the string. Please see https://aka.ms/logicexpressions#substring for usage details.'.
 
Categories:
I have the same question (0)
  • David_MA Profile Picture
    13,908 Super User 2026 Season 1 on at
    The issue with your Power Automate expression lies in the `indexof` function. If the substring `' - '` is not found in the `Home_Address` output, `indexof` will return `-1`, causing the `substring` function to fail and resulting in an invalid expression error. To handle this, you can add a condition to check if `' - '` exists in the `Home_Address` output before using `substring`. This can be done by using the `contains` function to ensure the substring is present. If it is, the `substring` function will execute safely.
  • Chriddle Profile Picture
    8,634 Super User 2026 Season 1 on at
    Instead of substring(...) use the following to get the string up to the first "-":
    first(split(outputs('Home_Address')?['body/r59ccb065f2e84f9dac89313e4c80ce66'], '-'))

    or, if outputs('Home_Address')?['body/r59ccb065f2e84f9dac89313e4c80ce66'] might be null:
    first(
        split(
            coalesce(
                outputs('Home_Address')?['body/r59ccb065f2e84f9dac89313e4c80ce66'],
                ''
            ),
            '-'
        )
    )
    

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 250 Super User 2026 Season 1

#2
Expiscornovus Profile Picture

Expiscornovus 222 Most Valuable Professional

#3
Haque Profile Picture

Haque 174

Last 30 days Overall leaderboard