[Note: This use case/solution can be implemented in both Classic and Lightning Experience.]
I’d like to give a shout out to my community friend, John Lay, for being the inspiration for this blog post. He had recently reached out to me on advice on this very error in his process.
Ever create a process that references information in a related record and when you go and test it, you get the friendly Workflow Action Failed to Trigger Flow error?!
Chances are, when you review the flow fault error email, the email will most likely indicate that “The flow failed to access the value for myVariable_<FieldName> because it hasn’t been set or assigned.”
There is a known posted Salesforce issue on this, with a description of “A Process that makes a cross-object reference will fail when the foreign key (i.e. relationship field) the reference depends on is not populated.” Ok, this is true if you are referencing a field that may be blank. To resolve this, add another condition to check that the field is not blank.
However, what happens when you are referencing a field on a related record that you know has a value and your process still faults?! What the heck?! It’s a head scratcher. This has happened to me many times too. Process builder can be a bit funky at times (yes, that is a technical term) when it comes to looking up information on a related record.
My workaround in these situations is to create a formula field on the object you are running your process on that references the field that is causing the process to fail. Then update your process to reference the custom formula field and activate it. Run your test again and voila! Your process now works as expected!
In the post below, I will walk through the before and after.
Business Use Case: Addison Dogster is the system administrator at Universal Containers. She is working on a process where if a new contact record is created by a contact owner with the Sales Profile, a task will be created. Addison did not want to hardcode the ID for the Sales Profile so Addison created the process to run when the record is new and the contact owner’s profile name is “Sales Profile.”
She activated the process and went to test this by creating a new contact logged in as a user assigned to the “Sales Profile” profile. She received a process error.
And as the system administrator who last updated the process, she received the fault email. It says that the current owner’s profile name is now set. How can that be? Every user has a profile assigned and therefore, would have a profile name assigned.
Solution: Being the #AwesomeAdmin Addison is, she was able to come up with a workaround for this by creating a custom field on the Contact object that references the contact owner’s profile name. Then she updated the process to reference the custom field. She activated the process and tested it successfully by creating a new contact logged in as a user assigned to the “Sales Profile” profile. No fault error!
1.Create a custom formula field to reference the field from the related record. In this example, we are referencing the contact owner’s profile name.
Best practice tips:
- Don’t forget to provide a description so you and other/future admins know what this field is used for.
- Assign field accessibility as needed. Since this is a processing field, there is really no need to show this to the end user. So, set the field accessibility accordingly, don’t just hit Next, Next and add the field for all profiles and all page layouts.
2. Now, we need to correct the process builder that will execute the process when a new contact is created by a contact owner assigned to the “Sales Profile” profile.
Update the build formula in the criteria node to reference the custom formula field created in Step 1. Save the changes and activate the process.
Now, before you deploy the changes to Production, don’t forget to test your configuration changes.
- Log in as the Sales Profile user.
- Create a new contact.
- Verify that the immediate action.
- The process builder and custom field can be deployed to Production in a change set (or can be deployed using a tool such as Dreamfactory’s Snapshot).
- You will find the process builder in a change set under the Flow Definition component type.
- Add the FLS permissions to the various profiles, as needed.
- Activate process builder as it is deployed as inactive in Production.
7 thoughts on “The flow failed to access the value for myVariable_Field because it hasn’t been set or assigned.”
Great post, Jennifer. Thanks for the tip!
Glad you found it helpful
it won’t worked for me:(
What didn’t work?
Still useful 2 years later. It saved the say!
When debugging the flow, the error occurred during flow and sent codes with messages.
Error Occurred During Flow “Test_Email”: The flow failed to access the value for sample_order.Owner: User. Name…
Please help me out to under these codes means and how to resolve it-
Error ID: 1694603670-371493 (973420906)
Salesforce Error ID: 1694603670-371494 (404447892)
I appreciated your help/support in this matter.
I don’t work for Salesforce. I don’t have access to error codes and what they mean. You will need to open a case with Salesforce Support for them to assist you or try Googling the code and see if anyone has posted information about it.
Comments are closed.