If an action attribute is toggled off, it has no representation in Flow metadata. If it’s toggled on but empty, it is represented with no value. In the metadata below, two simple send email actions are showed.In the top one, the two Email Addresses are toggled off:

and there’s no presence (i.e. no ‘input parameter’ elements in the metadata.)

In the bottom one, they’re toggled on:

..and there’s a presence in the metadata

This difference affects how Flow deals with the attribute when calling apex.

In the case where there’s nothing, Flow doesn’t pass an input:

Here’s a demonstration. This flow has two copies of an apex action that has three optional params, all Strings:

We’ll configure the first copy to have all the toggles off:

We’ll configure the second copy to have the toggles on, with the first input having a literal value ‘foo’ and the other two having no value:

When we run this Flow, this is what Apex sees:

In the first result, at 069 timestamp, we’re seeing the first call to apex. no inputs were passed for the the toggled-off values, and so apex sets the inputs to null. In the second case at 071, an empty string has been passed for the two cases where the input was toggled on but received no value.

What happens if we use a complex type like a Contact collection?

If it’s toggled off, Flow will again not send anything to Apex and Apex will show null for the input. If it’s toggled on but left empty, Apex will throw a type-mismatch error.

Takeaways

When writing invocable actions:

  1. keep in mind that any optional input can show up as null simply because the flow builder has toggled it off. Either make the input required or check all the inputs for null before you try to reference them or act on them.
  2. keep in mind that a toggled-on input with a primitive type might show up as an empty string.