I haven't blogged in forever... I have an excuse. Here she is:
My beautiful girl, Teagan Elizabeth Goerke
I had to give you all a good reason for being absent for so long. Now that the cute stuff is over, let's get down to business. Process Builder business that is.
I recently ran into this scenario and you might run into it too. I'll share how to fix it.
Business Scenario: Old records have no Record Type associated with them but more recent records do have a record type assigned
Error: Process fails with "The flow failed to access the value for [example] because it hasn't been set or assigned."
The more relevant error in our scenario is this:
Error element myDecision (FlowDecision).
The flow failed to access the value for myVariable_current.RecordType.Name because it hasn't been set or assigned.
When records don't have a record type assigned they technically do. It's called the Master Record Type and each object gets one when it's created, even standard objects. You just can't see it. So, it's odd that this error would come up with this scenario. I would expect it if we were working with a lookup variable that wasn't required. But I didn't expect it for Record Type. But it seems Process Builder can't see the Master Record Type either. Bummer.
We have two fixes:
- Update all our records with a Record Type - Somewhat impractical for some situations
- Design our Process Builder to work with blank Record Types - Much more practical
I'll focus on #2.
You should read this article as it describes the fix: https://help.salesforce.com/articleView?id=Process-fails-with-The-flow-failed-to-access-the-value-for-example-because-it-hasn-t-been-set-or-assigned&language=en_US&type=1
But here's a walk through:
No Record Type
Now our Process
In our first design we only accommodate for the Record Type:
But this design will cause errors for blank record types.
A better design is to first check for a blank record type as well as a specific record type. Like this:
It's important to note that you should always put the blank Record Type criteria step as always before any additional Record Type criteria evaluation against other values. It doesn't have to absolutely be first but it needs to be before all the other Record Type references.
As a best practice from a Design perspective, if your Object contains records with blank Record Types then you should build your Processes to accommodate those records or your users will get errors and no one likes flow errors.