[SalesForce] How to tell which Validation / Workflow rule caused exception

I am using a batch class to mass change the case owner from one queue to another, but during the update process I am returned the following exception:

FATAL_ERROR System.DmlException: Update failed. First exception on row 2 with id XXXXXXXXXXXXnARA; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Please Remove  CustomField: [CustomField__c]

How can I identify which validation rule or workflow rule is causing this exception?

I opened the case record the value in the field is $1.00. Maybe something to do with type? I wouldn't think so as I am ONLY changing the case owner.

The only line reference I am provided in the debug log is the line in which the case update called (line 25).

Just before the exception the log shows:

WF_ACTIONS_END - Field Update: 29; Flow Trigger 29; 
CODE_UNIT_FINISHED - Workflow: Case
DML_END - [25]|

Best Answer

Validation Rules

With validation rules I will go to the object's validation rule page (for standard objects or just the object page for custom) and ctrl+f the error message. In your case "Please remove...". This will usually find the error; however, if the validation error was added to a field via code you'll have to search your code for the error. I use Eclipse file regex search for the error text in these cases.

Workflows/PBs

For workflows or process builders this is a bit more challenging but if you scroll up in the debug logs slowly and read them line by line you can usually dig out the name. You may also get an email outlining the error that will tell you the name.

One of the things to keep in mind is that if you have several workflows or PBs that chain together it's very possible that the error is happening in a subsequent PB and not necessarily the one throwing the error. At the end of the day the debug logs are your friend. As boring as it is, reading the logs line by line is the best way to get a thorough understanding of what happens.

You can also change debug levels which will help you reduce the clutter in the logs so you can skip over information that's not as important.

Related Topic