0
public class addAttendee {
 public Account accounts;
 public Contact del;
 public Account acc1;
 public List<Contact> addattendeeList {get;set;}
 public List<Contact> delattendeeList {get;set;}
 public List<Contact> attendeeList {get;set;}
 public List<Contact> delAttendees {get; set;} 
 public Integer totalCount {get;set;}
 public Integer rowIndex {get;set;}


 public addAttendee(ApexPages.StandardController controller) {



    acc1=[Select Name from Account where Id=:ApexPages.currentPage.getParameters().get('Id')];
 attendeeList =  [Select Id, firstName, LastName, Email, Phone,Account.Name  from Contact where Id =:ApexPages.currentPage.getParameters().get('Id')];
     System.debug(LoggingLevel.Info, 'Your info');
 totalCount = attendeeList.size();
 System.debug('Account Id ****'+accounts.Id);
 delattendeeList = new List<Contact>();
 delattendees = new List<Contact>();
 }

 public void addRow(){
 addattendeeList = new List<Contact>();
 attendeeList.add(new Contact(AccountId = ApexPages.currentPage.getParameters().get('Id')));
 }

 public PageReference ave(){

 upsert attendeeList;
     upsert acc1;
 delete delattendeeList;
 return (new ApexPages.StandardController(accounts)).view();
 } 


 public PageReference cancel(){

    PageReference pr = new PageReference('https://ap4.salesforce.com/001/o');
    pr.setRedirect(true);
    return pr;
}

 public void deleteRow(){

 rowIndex = Integer.valueOf(ApexPages.currentPage().getParameters().get('rowIndex'));
 System.debug('rowbe deleted ' + rowIndex );
 System.debug('rowm to be deleted '+attendeeList[rowIndex]);
 del = attendeeList.remove(rowIndex);
 delattendeeList.add(del);

 }
}

I want to get the id of account on the current visualforce page so that I can add/delete multiple contacts for that particular account. But I am getting error as Method does not exist or incorrect signature: ApexPages.currentPage.getParameters() Please help me

0

2 Answers 2

3

currentPage is a method of ApexPages and not a property.

change this

ApexPages.currentPage.getParameters().get('Id')

to

ApexPages.currentPage().getParameters().get('Id')
0

Can you try getting AccountId in Constructor and then use it for passing the parameter so that you will get Id as soon as the page gets Loaded.

try like following:

public class addAttendee {      
  public Id accountIdParam ;

  public addAttendee(ApexPages.StandardController controller) {
     //Store the Id in variable at page Load and use it across the class
     accountIdParam = ApexPages.currentPage().getParameters().get('Id');    
  }

public void addRow(){
 addattendeeList = new List<Contact>();
 attendeeList.add(new Contact(AccountId = accountIdParam));
}


this will make your code more reusable also it should be

ApexPages.currentPage().getParameters().get('Id');

you are missing () in currentPage()

Thanks,
Nachiket

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.