You need to sign in to do that
Don't have an account?

Systems Error - Please help
Hi Team,
I have the following code which is bringing me headaches :)
public with sharing class ApexClassHomeWork
{
public List<Account> accs {get; set;}
// retrieves the list of accounts backing the page
public ApexClassHomeWork()
{
accs=[select id, Name, BillingStreet, BillingCity, BillingPostalCode FROM Account WHERE Name LIKE 'Test%' LIMIT 10];
}
public void createContact(Id acctId)
{
for(Integer i=0; i<500; i++)
{
Contact c = new Contact(AccountId=acctId);
insert c;
}
}
}
When calling the method "create contact", I get these errors messages:
1. "LastName is required" - What do I need to update to resolve this issue?
2. "Too Many DML Statements 151"
3. "Too many query rows: 500001"
Please help !!
I have the following code which is bringing me headaches :)
public with sharing class ApexClassHomeWork
{
public List<Account> accs {get; set;}
// retrieves the list of accounts backing the page
public ApexClassHomeWork()
{
accs=[select id, Name, BillingStreet, BillingCity, BillingPostalCode FROM Account WHERE Name LIKE 'Test%' LIMIT 10];
}
public void createContact(Id acctId)
{
for(Integer i=0; i<500; i++)
{
Contact c = new Contact(AccountId=acctId);
insert c;
}
}
}
When calling the method "create contact", I get these errors messages:
1. "LastName is required" - What do I need to update to resolve this issue?
2. "Too Many DML Statements 151"
3. "Too many query rows: 500001"
Please help !!
public void createContact(Id acctId)
{
list<contact> Cs = new list<contact>();
for(Integer i=0; i<500; i++)
{
Contact c = new Contact(firstname ='test', lastname='tst', AccountId=acctId);
cs.add(c);
}
insert cs;
}
I am working on this and now I am having trouble only with number 3. "Too many query rows: 500001"
I understand the governance limit where you cannot query more than 50000 records in a single query. How do I add a filter to prevent this from happening?