4

I have created a "Validation rule" on "Opportunity" object in Sandbox based on my requirement. It worked out fine. Now i would like it to move into production. I just copied the validation rule from Sandbox and pasted into production by logging in. Is this the correct method of doing it or we need to use migration tools such as Change Sets or Force.com IDE?

4

While this method of copying it directly into production does technically work, it's generally a good idea to deploy it through a change set or another dev tool (Mavens Mate, Eclipse, IDE, Ant, etc.). The advantage of doing this is that all of your test code is run with the new validation rule, so you can see if the new validation rule causes any test failures in your production environment.

Let's say for instance, you have a trigger on your opportunity object that creates a new case if a certain attribute is set. This trigger passes your test code and works well in your production environment. Lets now assume you have a new Validation Rule on the case object that requires a certain combination of fields. Your Opportunity trigger that is creating this case does not set these fields so your trigger will now fail due to this validation rule. If you simply copy and pasted this rule into production, you will now start to have trigger failures on your opportunity object and you may not know why. This is particular important when you have multiple people maintaining an org. So for instance, you as the admin, created this VR, and the developer who maintains the trigger, had no idea.

If you had used a change set to migrate the VR, then your test code would have failed (assuming you have proper test code in place). Then you would know there was an issue with the trigger prior to it being in production and you can work on the trigger to work well with the validation rule.

So in short, will pasting it work, technically, yes. Is it a good practice, no.

I hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.