Site icon UnofficialSF

Automatic Output Handling and Null Checking

Automatic Output Handling and Null Checking

Flows often need to check the results of a Get Records query and act in one way if there is at least one result and another way if there are no results. This is generally done by checking for null.

Historically, this was often done by using this checkbox:

If no records are returned, and this checkbox is checked, the ID value in the above image would be set to null. A Decision element could then inspect that field for null.

This solution will continue to work in Flow Builder but is no longer the recommended approach for accomplishing this.

Instead, the Flow team recommends using Automatic Output Handling and checking whether the object itself is null instead of checking its fields. In Automatic Output Handling, the reference is created automatically here:

In the downstream Decision element, instead of referencing a manual variable, you reference the Get Records query itself:

and you inspect it for null by using the Is Null operator directly on the reference.

This is a smoother solution, with fewer steps, than the old approach involving the setting of fields to null.

If you’re used to testing null by using the ID, be careful when you get to this point:

Flow is arguably steering you towards the Id value. However, the right thing to do if you want to test the object for null is to click outside the field. That will cause the object itself to be the reference and not its field.

If you select a field of the output reference, and no results are returned, you’ll get an error message like this: The flow failed to access the value for Get_Account.Id because it hasn’t been set or assigned. So, our recommendation is to select and test the reference itself and not to worry about the fields.

Roadmap

By the end of 2020, the team expects to complete an implementation of ‘pills’. This creates a friendlier label. In the example below, it’s a little clearer that the reference is referring to outputs from the upstream element:

On the other hand, a label like this arguably makes it less clear that you want to test it for null as an object and not test one of its fields.

Skip to toolbar