Skip to main content

Notifications

Power Automate - Building Flows
Answered

Add if statement to expression

Posted on by 98
Hi all,
 
I have the following expression that shortens URL links for me. Source is a Sharepoint list:
concat('<a href="', item()?['xxx'], '">xxx</a>')
 
The expression pulls the URLS from a SharePoint list, converts them into HTML and finaly send it as a report via email.
 
Unfortunately, "xxx" entries are also made where no URL has been set in the Sharepoint list.
I would like to add an if statement that, if URLs are not set, gives a note such as "please hand in later" as non url, just as non-executable text.
 
How do I best proceed?
 
Regards
  • Verified answer
    EKarim Profile Picture
    EKarim 10,148 on at
    Add if statement to expression
    Hi vipfafen,
     
    If I have understood correctly, you could try the following expression in a compose action: 
     
    if(empty(item()?['xxx']), 'please hand in later', concat('<a href="', item()?['xxx'], '">xxx</a>'))
     
    Here's a demo flow:
     
     
     
    Ellis
     
     
     
     
  • Suggested answer
    David_MA Profile Picture
    David_MA 7,320 on at
    Add if statement to expression
    I would do the following if I am understanding what you need correctly:
    1. Add a string variable to your flow and set the default value to "please hand in later".
    2. Add a condition to your flow to check that the URL exists, if it does, on the yes side of the condition, set the variable to your expression.
    3. Then use the variable in your e-mail.
     

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

October 2024 Newsletter…

October 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #4 How to Conntact Support…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 142,733

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,750

Leaderboard