cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Medoomi
Helper V
Helper V

Compose html - conditional <br> (if a field is null or empty)?

I have a compose step in flow, which writes html. Within this html, I have a field for the 2nd line of an address. Not everyone has a 2nd line in their address, so I wondered how I might write an expression which inserted "<br>" any time the field did not have a blank, or null value.

The expression I use to retrieve the 2nd line of the address is the following:

items('Apply_to_each')['Address2ndLine']

This field retrieves either a string, or null value. I would like to test for whether the string was blank, or the result, null... and if it is neither, to insert "<br>"

Any direction how I might write the expression?

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
abm
Super User
Super User

Hi @Medoomi 

 

Try the below

 

if(greater(length(items('Apply_to_each')['Address2ndLine']),0),items('Apply_to_each')['Address2ndLine'],'</br>')

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

View solution in original post

2 REPLIES 2
abm
Super User
Super User

Hi @Medoomi 

 

Try the below

 

if(greater(length(items('Apply_to_each')['Address2ndLine']),0),items('Apply_to_each')['Address2ndLine'],'</br>')

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

Greetings @abm 

Just deleting my last message, I changed the code to the following, which works fine:

if(greater(length(items('Apply_to_each')['Address2ndLine']),0),'<br>','')

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (1,783)