3

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:

  1. 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.
  2. 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.

4
  • what does the debug log say?
    – cropredy
    Commented Apr 9, 2016 at 1:22
  • Do you expect a record that fails validation to be successfully inserted / updated? What do you expect to happen?
    – Eric
    Commented Apr 9, 2016 at 3:54
  • Can you clarify if you have an auto launched flow that is triggered by process builder, or if this is a flow w screens?
    – gorav
    Commented Apr 10, 2016 at 23:54
  • And you should get a flow failure email. What does that say? It should elaborate on why the flow failed. Is the field that you blank out / fill back used in the flow?
    – gorav
    Commented Apr 11, 2016 at 0:16

1 Answer 1

2

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:

  1. Loads the new record field values from the request and overwrites the old values.

If the request came from a standard UI edit page, Salesforce runs system validation to check the record for:

  • Compliance with layout-specific rules
  • Required values at the layout level and field-definition level
  • Valid field formats
  • Maximum field length

When the request comes from other sources, such as an Apex application or a SOAP API call, Salesforce validates only the foreign keys. Prior to executing a trigger, Salesforce verifies that any custom foreign keys do not refer to the object itself.

Salesforce runs user-defined validation rules if multiline items were created, such as quote line items and opportunity line items.

Next, Before Triggers fire, then Item number 4 occurs:

  1. Runs most system validation steps again, such as verifying that all required fields have a non-null value, and runs any user-defined validation rules. The only system validation that Salesforce doesn't run a second time (when the request comes from a standard UI edit page) is the enforcement of layout-specific rules.

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.

You must log in to answer this question.

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