Welcome to deBUG.to Community where you can ask questions and receive answers from Microsoft MVPs and other experts in our community.
1 like 0 dislike
225 views
in Power Automate by 42 51 58

I'm working on a Power Automate flow that pulls data from SharePoint and sends it via email. One of the fields in the SharePoint list is optional (e.g., "Comments"), so sometimes it's empty (null). When the flow tries to use this field in an email body or condition, it fails with an error like:

"The template language function 'toLower' expects its parameter to be a string. The provided value is of type 'Null'."

I tried using the value directly like this:

toLower(triggerOutputs()?['body/Comments'])

But it breaks when the Comments field is blank. How can I safely handle null values in Power Automate so my flow doesn't fail if a field is empty? Is there a way to provide a default value or check for null in a cleaner way?


1 Answer

1 like 0 dislike
by 49 63 112
selected ago by
 
Best answer

Check iF value null in Power Automate

When you're working with fields that may be blank or null, you need to protect your expressions using functions that handle nulls gracefully otherwise, your flow will fail.
The best approach is to use the coalesce() function, which returns the first non-null value from the list you give it.

Example using coalesce()

Instead of this (which fails if the value is null):

toLower(triggerOutputs()?['body/Comments'])

Use this:

toLower(coalesce(triggerOutputs()?['body/Comments'], 'No comments provided'))

This means:

  • If Comments has a value → use it
  • If it's null → use "No comments provided" instead

Other Helpful Functions

use empty() to Checks if a field is null or empty

 if(empty(triggerOutputs()?['body/Comments']), 'N/A', triggerOutputs()?['body/Comments'])

Best Practice Tips

  • Always wrap expressions using dynamic content (especially from SharePoint or Dataverse) in coalesce() or if() when you're not sure if the field will always have a value.
  • If you're using a field in an email body, condition, or string conversion, it's safer to assume it might be null.
If you don’t ask, the answer is always NO!
...