• Rachel Zelkina 18
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 1
    Replies
We are no longer able to our OpportunityObject via Excel and Powerbi. We receive the following error or similar (different codes) in both
applications. DataSource.Error: An unexpected error occured. Please include this ErrorId if you contact support: 1453467511-3909(1633467924).

Our Opportunity object is the most heavily customized object in our org by far. We are at the 500 limit on fields and there are numerous workflows; validations; and process flows that support it. However, we never received this error until recently.

.User-added image
A method in an existing test class is thtrowing this error when I run the test: System.LimitException:
Too many DML rows: 10001
Stack TraceClass.ContractSnapshotCreateDelete.processDelete: line 64, column 1
Class.Lead_Note_test.myUnitTest4: line 251, column 1

This is the failing unit test within the apex class and below that is lines 60-70 of the refernced class. We've just created 1000's of contract and contract snapshot records so I think thats why its failing. Im just not sure how to fix it. Please help!
 
static testMethod void myUnitTest4() {
// ****Contract Snapshot Create/Delete
    account a = new account(Name='Test');
    insert a;
    a.Name='Test4';
    update a;
    contract c = new contract(accountId=a.id, startdate=date.today(), contractterm=1, status='Draft', active__c=true);
    insert c;
    ContractSnapshotCreateDelete controller = new ContractSnapshotCreateDelete();
    contract_snapshot__c cs = new contract_snapshot__c();
    cs.account__c           = a.id;
    cs.contract__c          = c.id;
    cs.YYYYMM__c            = '201706';
    insert cs;
                                 controller = new ContractSnapshotCreateDelete();
    controller.YYYYMM       = '201706';
    controller.create       = true;
    controller.processCreate();
    controller.deletex      = true;
    controller.processDelete();    
    
}

Below are lines 60-76 of ContractSnapshotCreateDelete Class

ContractSnapshotCreate/Delete 
   

public PageReference processDelete() {
        if(deletex){
            list<Contract_Snapshot__c> listContract_Snapshot = [SELECT Id, YYYYMM__c FROM Contract_Snapshot__c Order By YYYYMM__c desc LIMIT 10000];
            if(listContract_Snapshot.size()>0)      
           Delete listContract_Snapshot; 
                if(listContract_Snapshot.size() == 10000){
                    ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.INFO,'First 10000 records deleted, please click delete again');
                    ApexPages.addMessage(myMsg);                  
                } else {
                    ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.INFO, string.ValueOf(listContract_Snapshot.size()) + ' records deleted.');
                    ApexPages.addMessage(myMsg);              
                }
            }
        }        
        deletex = null;
        return null;
    }
When deploying a process flow or workflow rule to Production I received an error saying that there were too many dml statements for two test classes. I then reran the the tests via dev console (without deploying the change set) and saw the same errors. 

The tests weren't failing in a recently refreshed sandbox. So I created a new sandbox today and was planning on systematically deleting any changes made in production since last week when I refreshed the sandbox where the tests passed, however the tests also passed in the sandbox I created today even though they failed in Production! Whats happening?! How can tests fail in Production and not in a newly refreshed sandbox?
When deploying a process flow or workflow rule to Production I received an error saying that there were too many dml statements for two test classes. I then reran the the tests via dev console (without deploying the change set) and saw the same errors. 

The tests weren't failing in a recently refreshed sandbox. So I created a new sandbox today and was planning on systematically deleting any changes made in production since last week when I refreshed the sandbox where the tests passed, however the tests also passed in the sandbox I created today even though they failed in Production! Whats happening?! How can tests fail in Production and not in a newly refreshed sandbox?