Is there a way to force execution of all validation rules? Ultimately, I'd like to test an oppty against VR's, just as if you Edit/Saved, but without modifying its timestamps.

That way I can see how reported oppties are failing, without having to edit/change/touch live data.

  • 5
    best to do this in a sandbox
    – cropredy
    Apr 30, 2016 at 0:25
  • 2
    One ugly idea is to clone the opportunity and play around and then delete.
    – javanoob
    Apr 30, 2016 at 1:15
  • 3
    One thing to do is to use data loader to export records the meet the criteria. For example you have a rule where StageName = 'Pending' and SomeField = true, export records with those value. It takes a bit of time but you can get the records that fail each rule without modifying anything.
    – Eric
    Apr 30, 2016 at 3:44
  • 2
    Combine Eric's idea and stick results in sandbox -- safest solution.
    – cropredy
    Apr 30, 2016 at 5:54
  • 2
    Can't we do it through the test class?Like setting seealldata=true. I know this is not a valid approach for writing test class but i don't think we are concerned about that here.
    – Mr.Frodo
    Apr 30, 2016 at 6:08

2 Answers 2


I don't think there is any out-of-the box way to do this. Maybe you can quickly do this with some anonymous Apex code:

List<Opportunity> failingOppys = new List<Opportunity> ();
for (Opportunity o : [SELECT Id FROM Opportunity]) // Here you should select all fields that may cause validation
    Opportunity ocl = o.Clone (false, true, false, false);
    try {
        insert ocl;
        delete ocl;
    catch (Exception e)
        failingOppys.add (o);
System.debug (failingOppys);

This code is non-bulkified so you may hit some Apex limits after 100 records or so. Let me know if this approach could work for you and perhaps we could come up with a bulkified/batched version of it. How many opportunity records are we talking about?

  • Should be add not insert in your catch block?
    – Adrian Larson
    May 1, 2016 at 17:26

You could use Database.SavePoint and Database.RollBack(SavePoint sp). Here is a quick explanation on how to use it

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .