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
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,241 Super User 2025 Season 2 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,459 Super User 2025 Season 2 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

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
David_MA Profile Picture

David_MA 240 Super User 2025 Season 2

#2
Expiscornovus Profile Picture

Expiscornovus 201 Most Valuable Professional

#3
trice602 Profile Picture

trice602 172 Super User 2025 Season 2

Last 30 days Overall leaderboard