I have a screen flow where the user selects a pair of records. The flow attempts to get a related record that may or may not exist, then branches based on null/not null.

The relevant Get Records element uses "Choose fields and assign variables (advanced)" with "When no records are returned, set specified variables to null" enabled.

The Flow now works in my sandbox, but in the main org it still throws an "unhandled" fault because of missing field values (if getPE returns null). I added a fault handler but it has no effect. Also, it's not a Required field.

Flow Builder screenshot

Here is the Debug output:

GET RECORDS: getPE Find all PE__c records where: 
AoE__c Equals {!myAoE.recordId} (...) AND 
Program__c Equals {!getSP.Program__r.Id} (...) 
Store those records in {!myPE}. 
Save these field values in the variable: Id, LO__c 
Failed to find records. 
Error element Choose_SE (FlowScreen). 
The flow failed to access the value for myPE.Id 
because it hasn't been set or assigned.

Why is it claiming there's an error back in the original flow screen, when the screen doesn't reference the missing record at all?

Why is it working in one org but not the other? And how do I fix it?

  • 2
    Could you edit the question to show the specific flow element detail for the element that errors please, and include the full error message. Debugging the flow will help get the detail as to exactly where the error happens.
    – Phil W
    Jan 11, 2023 at 23:03
  • are you querying the related record even if the lookup Id value is NULL?
    – cropredy
    Jan 11, 2023 at 23:17
  • @PhilW screenshots & debugger messages added.
    – Foo Bar
    Jan 13, 2023 at 21:22
  • @cropredy it's a single Get Record element. I have to look for the record to find out if it exists or not, right?
    – Foo Bar
    Jan 18, 2023 at 15:22
  • Your screen element must be referencing a field in a null record. You have to check that the record variable is not null before referencing any fields in that record variable
    – cropredy
    Jan 18, 2023 at 17:47

2 Answers 2


Assuming there are no other admins making changes, the only thing that could be different without your knowledge between a sandbox and production would be a Salesforce Release preview. If it is that, or a bug, Salesforce Support should be able to support you.


In case anyone runs into this later -- I've dealt with this before in the past, although it's extremely rare.

I found that by using a separate text variable, then "Choose fields and assign variables (advanced)" with "When no records are returned, set specified variables to null" and assigning the Id to that text variable circumvented the issue.

I have no idea why this worked.

You must log in to answer this question.

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