[SalesForce] How to check if a record exists in Flow Builder

I have an autolaunched flow to create a record with particular field values, unless a record with the same values already exists. This answer offers a method for interactive flows. This answer says headless flows can do the job, but doesn't explain how.

Get Records successfully finds the record if it exists, but errors out if it doesn't.

Best Answer

https://help.salesforce.com/articleView?id=flow_ref_elements_data_get.htm&type=5

Scroll down on the get record screen and select "Manually assign variables (advanced)". There should be an option at the bottom to specify setting the variable to null when no records are returned. Now, you can add a decision to check if this variable is null.

enter image description here

Related Topic