function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
tsalbtsalb 

Help on Testing (Trigger, too many DML rows 10001)

Another board member helped me develop this trigger - but I need a little advice on where to head for testing this trigger. I Read through http://teachmesalesforce.wordpress.com/2011/05/07/how-to-write-a-trigger-test/ but had some hard time understanding...

 

From what I can understand, I'd have to create a contact, an order, and then try to populate the fields and do testing? Can anyone provide some guidance?

 

Edit - cleaned up my trigger a bit.

 

trigger lastEngagedDate on Order__c (after insert, after update) {

	set<id>must=new set<id>();
		for(Order__c o : Trigger.new) {
        	must.add(o.Vendor_Name__c);
        }
        
        Order__c o = [SELECT Valuation_Contracted_Date__c, Status__c, Vendor_Name__c
        		FROM Order__c
        		WHERE Vendor_Name__c IN:must 
        		ORDER BY Valuation_Contracted_Date__c DESC 
        		LIMIT 1];
            				
	List<Contact> vendor = new List<Contact>();
        if(o.Status__c=='Valuation Contracted' && o.Valuation_Contracted_Date__c!=null) {
	vendor.add(new Contact(Id = o.Vendor_name__c, Last_Engaged_Date__c = o.Valuation_Contracted_Date__c));
	update vendor;
        }

}

 

dmchengdmcheng

This Salesforce article may be clearer and simpler to start with:

http://wiki.developerforce.com/page/How_to_Write_Good_Unit_Tests

 

steve456steve456

Start with Order

 

Enter all tha mandatory fields and  if you have a lookup field on order write the test details for that look up object and reference it in order.

 

Keeping doing it backforth

 

 

last implement the test values in the way you want in the logic while updating or inserting

tsalbtsalb

Thanks for the help all - I have a question on how to insert a two lists (volume inserts) and then associate the list records of one list to the other (1:1 for the Ids).

 

Proposals has a lookup to Orders, and each Order needs a unique, "Accepted" proposal. This is what I have so far.

 

//Create List of Orders (Volume)
List<Order__c> ordList = new List<Order__c>{};

for (Integer i=0; i<200; i++){
	Order__c ords = new Order__c(
		property__c = property.Id,
		customer__c = a.Id,
		requester__c = c.Id,
		vendor_name__c = v.Id,
		valuation_contracted_date__c = Date.today().addDays(i),
		status__c = 'Valuation Contracted'
	);
	ordList.add(ords);
}insert ordList;

//Create List of Proposals
List<Proposal__c> rfpList = new List<Proposal__c>{};

for(Order__c ord: ordList){
	for (Integer x=0; x<200; x++){
		Proposal__c rfps = new Proposal__c(
			Order__c = ord.Id,
			vendor__c = v.Id,
			status__c = 'Accepted'
		);
		rfpList.add(rfps);
	}
}insert rfpList;

 

This gives me a Too many DML Rows:10001 error? It happens on when i insert rfpList;