Skip to content

Instantly share code, notes, and snippets.

@seanpat09
Last active December 19, 2018 17:50
Show Gist options
  • Save seanpat09/ebe6cc54da9c7177bfe7e631f7301d75 to your computer and use it in GitHub Desktop.
Save seanpat09/ebe6cc54da9c7177bfe7e631f7301d75 to your computer and use it in GitHub Desktop.
List<Account> testAccount = [SELECT Id FROM Account WHERE Name = 'Test Account'];
Account accountToArchive;
if (testAccount.isEmpty()){
accountToArchive = new Account(Name = 'Test Account');
insert accountToArchive;
} else{
accountToArchive = testAccount[0];
}
List<Opportunity> opps = new List<Opportunity>();
List<Task> toInsert = new List<Task>();
for (Integer i = 0; i < 100; i++) {
opps.add(
new Opportunity(
AccountId = accountToArchive.Id,
Name = 'TestOpp'+i,
StageName = 'Closed Won',
CloseDate = Date.today()
)
);
}
insert opps;
for (Opportunity o : opps) {
for (Integer i = 0; i < 75; i++) {
toInsert.add( new Task(
WhatId = o.Id,
Subject = 'Task ' + i,
Description = 'My Description'
)
);
}
}
insert toInsert;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment