Ask Search:
Fiona PartingtonFiona Partington 

Validation rule limit on custom object

I have created a custom object with 165 fields, almost every field requires 1-5 validation rules.  I am unable to combine the rules because I need there to be a specific error message at the correlating field so that the users know what they have done wrong and how to correct it.
I have to use a pre specified set of validation rules because my object is being used to collect data that will then be uploaded via csv file to another organisation.

The rules are all very simple e.g.

If field a is completed then field b is mandatory
field c cannot be greater than today
field d cannot be less than field e

etc

Is there a way to increase the limit of 100 validation rules per custom object?

or

Is there a way to create a validation rule for 1 field which includes several different rules and depending on which part it fails on you can specifiy the error message?

e.g.

If field A cannot be greater than field B   (error message: field A connot exceed field B)

and

field A cannot be less than field C     (error message: field A cannot be less than field C)

and

field A is mandatory if field D is completed   (error message: field A is mandotory when field D is completed)

Subramanyam MeareSubramanyam Meare
You can Merge the 2 different validation rule in to 1 , but you can't merge the Error message, However i would suggest to do the following mixup with Error message:-

error message: field A cannot be less than field C/error message: field A is mandotory when field D is completed

Then you can merge the 2 validation rule in to 1

Rajesh ShahRajesh Shah
Is there a way to increase the limit of 100 validation rules per custom object?
You will have to check this with Salesforce. I have heard cases where Salesforce have raised certain limits.


Is there a way to create a validation rule for 1 field which includes several different rules and depending on which part it fails on you can specifiy the error message?
No. As far as I know, this is not possible. Considering your example, a better would be to combine the validation rules and give a common error message. Eg: Field A cannot exceed field B and cannot be less than field C.

Now assuming that Salesforce cannot raise the maximum validation rules limit, the only option available to you would be to divide the validations into validations rules and validations through trigger. Also, keep in mind that before triggers exeute before Validations rules. Properly dividing validations between Validation rules and trigger will help in optimizing the performance.

Andrew SturtAndrew Sturt
You can combine validation rules as Subramanyam Meare suggests. The syntax for this is placing each rule inside parentheses and separating the rules with a double pipe. In other words, (validation 1)||(validation 2), or with actual code: (Quantity__c  <= 1)||(Quantity__c <= Merchandise__r.Quantity__c). Bear in mind, though, that you will only be able to create a single message (as Subramanyam noted). There may be a character limit on validation rules (possibly 3,900, which is the limit on formulas in all editions), but I could not find explicit documentation of this.

If your company absolutely needs more than 100 validation rules and they simply cannot be combined, you may want to consider changing the edition of Salesforce you are using to either the Unlimited or the Performance Edition, both of which allow up to 500 validation rules per object.

For more information on limitations, here's a link to the "Salesforce Limits Quick Reference Guide (https://success.salesforce.com/answers?id=90630000000ghFNAAY)".