I have Process Builder Flow that fails to trigger if a Validation Rule catches an error. If the VR doesn't fire, the record saves successfully (Process Builder runs). I have similar VRs and PB Flows on Leads and Contacts and it happens in both cases. Here are the 2 scenario details:
- I save a record with a field value update that will trigger a Workflow Rule and Field Update. That Workflow Field Update in-turn triggers a Process Builder Flow. The Workflow Field Update runs correctly, the Process Builder Flow triggers and runs correctly and the record saves.
- I repeat the process above but this time I leave a different field empty (to trigger the Validation Rule). When I click Save, the Validation Error is correctly displayed next to the empty field. I update the empty field and click Save again. Now I get an error: "The record couldn’t be saved because it failed to trigger a flow…"
I've had to turn off the Validation Rule for now…Please help.
Best Answer
See Triggers and Order of Execution in the Apex Developer Guide. When a record is being saved to the database, you'll notice that item number 2 is as follows:
Next, Before Triggers fire, then Item number 4 occurs:
A record doesn't reach Process Builder until Item 13 on the list of 20. If a record fails validation or any item on the list, it gets "rolled back" and never gets committed to the database. It seems that you're mistaking Validation Rules for Workflow Rules. Workflow Rules cause AfterUpdate triggers to fire again on records once and only once if they result in a field update (see items 10 and 11).
What you want to do (if anything) is to cause another workflow rule to fire. Better yet might be to create a visual flow that runs for this entire process so that both fields can entered properly without needing to have the record saved twice. Another option would be to create some kind of flow that runs when that field is empty. I'm not quite certain how you'd "trigger" the latter since it would require user input. At one point there were "flow triggers" which would run just like regular triggers to populate fields without user interaction.
With all that having been said, your message sounds like you're not creating any error handling in your flows to allow them to pause or recover when interrupted. You might want to look at Sample Flows that Wait for Events in the Visual Workflow Guide for some additional guidance and examples to help you solve your issues.