Getting errors with null fields
This article provides a solution to an error that occurs when you create a flow in Microsoft Power Automate.
Applies to: Power Automate
Original KB number: 4535432
In Microsoft Power Automate, when you create a flow, here's what could happen with null field that cause trouble:
You may be expecting wrong behavior when doing an action with null field.
If you aren't handling null fields correctly, you may be expecting runtime errors like:
InvalidTemplate. Unable to process template language expressions. The provided value is of type 'Null'.
- If a flow runs with a null field, it will cause:
- Wrong behavior: flow action's input is receiving null field, when it expects a different value.
- Use expression towards null fields. It will cause:
- Runtime error: expression expects its parameter to be a string, an object, or an array but receives null.
Flow error resolution
You can set up a condition check for null field. Here are the steps to create a condition check for null.
Add a new condition action.
Choose dynamic content output (for example, user email) you want to check.
Set the operation to be (for example) is not equal to.
Put the value field as the expression value null.
Runtime error resolution
You can also use the coalesce function to provide default values when a value is null. For example, using coalesce(trigger().outputs, '') will default to empty string when trigger().outputs is null.
If you're still getting a runtime error, it may be caused by reference null properties in an object. You should use the question mark operator ?. For example, to handle null outputs from a trigger, you can use this expression: