+ Start a Discussion
Sumit  61Sumit 61 

How to Add my custom related object in this code

I want to add Lead and Question__c.this object on this code, i tried but getting error

public with sharing class contrllr {

    Public id Current_Acc_Id;
    public Boolean isEdit { set; get;}
    public List<Contact> lstContact {set;get;}
    public contrllr (ApexPages.StandardController controller) {
        Current_Acc_Id = controller.getRecord().id;
        isEdit = false;
        lstContact = New List<Contact>(); 
        for(Account acc:[select id,name,(select lastName,firstName,name,id,email from contacts) from account where id=:Current_Acc_Id]){
           for(contact con:acc.contacts)
               lstContact.add(con); 
        }
    }
    public void editProcess(){
        isEdit = true;
    }
    public  void save(){
        
        if(lstContact.size() > 0){
            upsert lstContact;
            lstContact.clear();
        }
        
        for(Account acc:[select id,name,(select lastName,firstName,name,id,email from contacts) from account where id=:Current_Acc_Id]){
           for(contact con:acc.contacts)
               lstContact.add(con); 
        }
        isEdit = false;
    } 
    public void addContact(){
        lstContact.add(new Contact(AccountId = Current_Acc_Id));
        isEdit = true;
    }
}
EnreecoEnreeco
What error are you gettinh?

--
May the Force.com be with you!