Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

function/expression to check for blank values in power automate html table item

I have created a flow for sending an email to contract owners based on a excel if a condition satisfies. The email has a HTML table of related details attached to it. One of the required details is a formatted date value which may or may not be blank in sheet. The formatdatetime expression used for the date value in HTML table returns error due to the blank values present in date field of excel sheet. Even when I use condition block with this scenario, I am not able to create the HTML table as it will create two Select options to store data separately as per the condition. Please suggest some solution to get this solved. I have used the following formula which sends the error-

formatDateTime(addDays('1900-01-01', add(int(item()?['Column name']),-2)), 'dd-MMM-yyyy')

The error I get due to blank values is as- The template language function 'int' was invoked with a parameter that is not valid. The value cannot be converted to the target type.

like image 476
KachMi Avatar asked Nov 20 '25 07:11

KachMi


1 Answers

You can use "if"(if(expression, valueIfTrue, valueIfFalse)) method in expression. Just change the part of expression in your complete expression

from

int(item()?['Column name'])

to

int(if(equals(item()?['Column name'], null), '0', item()?['Column name']))

This expression will change the value to 0 if item()?['Column name'] is null. You can also specify any other value if you want.

like image 86
Hury Shen Avatar answered Nov 22 '25 05:11

Hury Shen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!