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

Viewed 5806

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.

3 Answers

Also, You can use the @empty() logic App function Click emptyFunction its check for empty string, Null Also Empty Collection

it Returns true when the input is empty (empty string, Null Also Empty Collection ), or return false when not empty.


int(if(equals(empty(item()?['Column name']), bool(1)), '0', item()?['Column name']))

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.

The following code worked for me:

if(equals(item()?['OFF-Board Date'],''),
null,addDays('1900-01-01',int(item()?['On-Board Date']),'MM/dd/yyyy'))

even this worked fine for me

if(empty(items('Apply_to_each')?['On-Board Date']),
null,addDays('1899-12-30',int(items('Apply_to_each')?['On-Board Date']),
'MM/dd/yyyy'))
Related