• Nikx1505
  • NEWBIE
  • 5 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 3
    Replies
Hai All

I have an requirement that when i enter account name in text box click on submit it display all the related contact records 
Please check my code

public class conbyacc {
    public String accname{set;get;}
    public list<Account> acclist{set;get;}
    public list<Contact> conlist{set;get;}
    public set<Account> accids{set;get;}
    public list<Contact> getcons(){
        acclist.clear();
        conlist.clear();
        accids.clear();
        acclist=[select Id,name from Account where name=:accname];
        for(Integer i=0; i<acclist.size(); i++){
            accids.add(acclist[i].Id);  // Getting Error
        }
        conlist=[select name,accountid from Contact where accountid IN:accids];
        return conlist;
        
    }

}


Thanks In Advance
Sampath Palli
Hello, I am working on this trigger where I want to update a custom date field only when certain fields on the table are changed. I am assuming that Contact and Person Account has shared fields, so how would I create this trigger? (may be 1 for Account and another for Contact?)

Thank you, a simple example would be great! :)