6

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.

6
  • 2
    How are you setting up your "Get Records"? You should be able to store a null value if no records are returned and then check if that variable is null to confirm if it exists or not. Commented Nov 12, 2019 at 20:02
  • you can also get the count of records returned and assign that to a variable for testing > 0
    – cropredy
    Commented Nov 12, 2019 at 20:15
  • @KrisGoncalves thanks, using "Manually assign variables (advanced)" allows the null to be stored instead of exiting. You should post that as an answer.
    – Foo Bar
    Commented Nov 13, 2019 at 11:58
  • @cropredy I haven't found that option. Do you know where it is?
    – Foo Bar
    Commented Nov 13, 2019 at 11:59
  • 1
    example of equals count : jenwlee.files.wordpress.com/2018/06/flowcollectionwithcount.gif
    – cropredy
    Commented Nov 14, 2019 at 19:05

2 Answers 2

11

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

3

Salesforce now recommend using Automatic Output handling. See https://unofficialsf.com/automatic-handling-null/ Automatically store all fields then check for the return reference being null.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .