When you create a validation rule in salesforce and click on check syntax button, Salesforce checks only the syntax of the formula and not the formula logic. For example, (w+x+y)*z and w+x+(y*z) would result in two completely different results.

So to check if the validation rule really fits your business logic you then need to test it by creating/updating records to see if your validation rule fires on the right records or not.

There might be a more smart way to test this without spending so much time on testing your logic by altering the records.

One way is to create a formula field. Yes, that’s right a formula field.

Validation rule in salesforce result in a Boolean true or false just like a checkbox field. So, if you ever want to test your formula logic of a validation rule simply create a checkbox formula field and put your validation rule formula in it. This new checkbox formula field will then show you the result in True/False for each record of the object and you can fetch the report or use list views to see if the logic of the formula satisfies the correct records or not.

The records which will show the checkbox as True will mean that the validation will fire on this record on the present set values of the record. If the checkbox on the records are false then those records will bypass the validation rule.

However, since this method relies on the current field value of the records this method is not suitable when you are using functions like ISCHANGED and PRIORVALUE.


0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *