Skip to main content

Notifications

Power Automate - Building Flows
Unanswered

Concat issues

Posted on by 20
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.'.
 
  • Chriddle Profile Picture
    Chriddle 7,086 on at
    Concat issues
    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'],
                ''
            ),
            '-'
        )
    )
    

  • David_MA Profile Picture
    David_MA 7,582 on at
    Concat issues
    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.

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,591

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,090

Leaderboard