• Luciano Castro 2018
  • NEWBIE
  • 10 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 21
    Replies
How can I add a filter to this code to prevent this error message?

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)
    {
       list<contact>contList = newlist<contact>();   
       for(Integer i=0; i<500; i++)
        {
            Contact c = new Contact(AccountId=acctId, "last name");
            contList.add(c);
        }
        if(contList.size()>0)
             update contList;
    }
}
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 !!
 
How can I transfer one product from one pricebook to another?
I would like to know what are the impacts on the closed opportunities if I change the pricebook. 

For example: we have this product called Revenue ( Schedule Revenue) from pricebook A . 

I need to move that product to Pricebook B but do you know if the schedule revenue will carry over?
I am trying to create a validation rule to enforce users to fill out a lookup field based on a multi-select. Here is the trick

Multi-Select has 3 options(A,B,C) and we have 3 different lookups called A,B,C

If I select A from the picklist then I have to fill out lookup A
If I select B then fill out lookup B
If I select C then fill out lookup C 

However,

if I select A,B fill out lookup A,B
if I select A,C - then lookup A, C
if I select B,C - then lookup B,C 

Any thoughts how I can write this validation?

 
I am trying to create a validation rule to enforce users to fill out a lookup field based on a multi-select. Here is the trick

Multi-Select has 3 options(A,B,C) and we have 3 different lookups called A,B,C

If I select A from the picklist then I have to fill out lookup A
If I select B then fill out lookup B
If I select C then fill out lookup C 

However,

if I select A,B fill out lookup A,B
if I select A,C - then lookup A, C
if I select B,C - then lookup B,C 

Any thoughts how I can write this validation?

 
How can I add a filter to this code to prevent this error message?

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)
    {
       list<contact>contList = newlist<contact>();   
       for(Integer i=0; i<500; i++)
        {
            Contact c = new Contact(AccountId=acctId, "last name");
            contList.add(c);
        }
        if(contList.size()>0)
             update contList;
    }
}
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 am trying to create a validation rule to enforce users to fill out a lookup field based on a multi-select. Here is the trick

Multi-Select has 3 options(A,B,C) and we have 3 different lookups called A,B,C

If I select A from the picklist then I have to fill out lookup A
If I select B then fill out lookup B
If I select C then fill out lookup C 

However,

if I select A,B fill out lookup A,B
if I select A,C - then lookup A, C
if I select B,C - then lookup B,C 

Any thoughts how I can write this validation?