+ Start a Discussion
Jeffrey BieberJeffrey Bieber 

Help with Apex Page Redirect Controller.

Hey All. Hoping to get some help on a Controller issue I can't resolve. I'm pulling a parameter from a URL  and using that in a SOQL query that will feed my redirect Parameter. Im getting a "Method does not exist or incorrect signature: void put(String, Account) from the type Map" error. 

Here is my code. Thank you very much in advance.

public class MyController {
 
    private final Account account;
 
    public MyController() {
        account = [SELECT FirstName,LastName,Measurement_Summary_ID__C  FROM Account 
                   WHERE Id = :ApexPages.currentPage().getParameters().get('recid')];
    }
 
     public PageReference validateAndRedirect(){

      //Write your logic here and redirect
      PageReference pageRef = new PageReference('/apex/Patient_Health_Dashboard');
      pageRef.setRedirect(true);
      pageRef.getParameters().put('id',account);
      return pageRef;

 }
}
Best Answer chosen by Jeffrey Bieber
Vishwajeet kumarVishwajeet kumar
Hello,
Put method supports string values(not object).

Try :     pageRef.getParameters().put('id', account.Id);


Thanks

All Answers

Vishwajeet kumarVishwajeet kumar
Hello,
Put method supports string values(not object).

Try :     pageRef.getParameters().put('id', account.Id);


Thanks
This was selected as the best answer
Jeffrey BieberJeffrey Bieber
Thank you Sir! That fixed the issue.