I encountered the strangest error today, and I wanted to make sure that this is a real thing and not just a silly mistake of mine.
I had a validation rule on Lead
:
And(
isblank(Address),
$RecordType.Name = "Internal Leads"
)
When creating a Lead object with only the State
part of the address populated in a test class, I got the following error:
System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Validation Formula "Validate_Address" Invalid (Programmer Error: Can't get an enum with a fieldId for a compound field): []
I'm completely aware of how to fix the problem, just split the Address field into its parts. But I want to make sure I am right in interpreting what just happened. Is this in fact a runtime error when evaluating a validation rule?
There is a trigger on lead which requires has some dynamic logic that references the schema, so it may explain the direction the error took, but it doesn't explain why it happened.