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

Symptoms

In Microsoft Power Automate, when you create a flow, here's what could happen with null field that cause trouble:

  1. You might be expecting wrong behavior when doing an action with null field.

  2. If you aren't handling null fields correctly, you might be expecting runtime errors like:

    • InvalidTemplate. Unable to process template language expressions. The provided value is of type 'Null'.

    Screenshot of the invalid template runtime error.

Cause

  • 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.

  1. Add a new condition action.

    Screenshot to add a new condition action in the Choose an action window.

  2. Choose dynamic content output (for example, user email) you want to check.

    Screenshot to choose the dynamic content output that you want to check.

  3. Set the operation to be (for example) is not equal to.

  4. Put the value field as the expression value null.

    Screenshot 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.

Screenshot to use the coalesce function to provide the default values when a value is null.

Note

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:
@coalesce(trigger().outputs?.body?.<someProperty>, '<property-default-value>').

For more information, see Coalesce and Operators.