You need to sign in to do that
Don't have an account?
bouscal
Why won't this create child cases for testing?
Not sure what's going on, the parent cases get insert but the child cases do not.
I've also tried adding the children cases to the same list as the parents and inserting them all at once, which works, but doesn't hold the link to the parent. They're all standalone cases.
List <Case> lCase = new List<Case>(); List <Case> nCase = new List<Case>(); for(integer i=0; i<20; i++){ Case cas1 = new Case( recordtypeid=rsc, accountid=acc1.id, contactid=con1.id, Case_Name__c='John Doe', case_phone_number__c='(800) 555-1212', subject='Test Recycling Case', origin = 'Phone', status='Escalated to Management', Escalated_To__c='Return to Liaison', description='This is a parent Case'); if(math.mod(i,2)==0){ cas1.Case_Phone_Number__c='(800) 555-1212'; } lCase.add(cas1); Case cas2 = new Case( recordtypeid=pdc, parentid=cas1.id, accountid=acc1.id, contactid=con1.id, status='Closed', Case_Name__c='John Doe', case_phone_number__c='(800) 555-1212', subject='Escalation: Test Recycling Case', description='This is an escalated Case'); nCase.add(cas2); }
I've also tried adding the children cases to the same list as the parents and inserting them all at once, which works, but doesn't hold the link to the parent. They're all standalone cases.
First you have to insert the parent because you don't have its Ids. After you perform the operation, you will have to get the parent's Id and then insert the children.
Regards.
Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.
All Answers
First you have to insert the parent because you don't have its Ids. After you perform the operation, you will have to get the parent's Id and then insert the children.
Regards.
Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.
Adding to Zuinglio's comment, here's what your test setup might look like.
I need the child cases to be tested and if the first insert has fired the trigger the 2nd insert won't because the trigger is executing and I've coded to block the recursion.