You need to sign in to do that
Don't have an account?
Custom Button in Custom Controller Help
This is my custom controller. I am not sure what to do in my account query so that when the Cancel method calls it the account page is returned. Any help or suggestions would be greatly appreciated. thanks!
public class ViewAllIncidents {
public Account acct{
get{
if(acct == null){
acct = [SELECT a.id, a.name
FROM Account a
WHERE id =: apexpages.currentpage().getParameters().get('id')];
}
return acct;
}
set;
}
public ViewAllIncidents() {
this.theIncidents = [SELECT c.Account.Name, c.CaseNumber, c.Status, c.due_date__c, c.subject, c.Contact.Email, c.description
FROM Case c
WHERE c.AccountId = :ApexPages.currentPage().getParameters().get('acctId')];
}
public List<Case> theIncidents { get; set; }
public PageReference cancel() {
//cancel method to return to the account detail page
return new ApexPages.StandardController(acct).view();
}
}
Hey
Try this,
public String aId = apexpages.currentpage().getParameters().get('id');
public PageReference cancel() {
//cancel method to return to the account detail page
return new PageReference('/'+aId);
}
The return new ApexPages.StandardController(acct).view(); call can only be used from within a standard controller extension.
Wes
All Answers
Hey
Try this,
public String aId = apexpages.currentpage().getParameters().get('id');
public PageReference cancel() {
//cancel method to return to the account detail page
return new PageReference('/'+aId);
}
The return new ApexPages.StandardController(acct).view(); call can only be used from within a standard controller extension.
Wes
Thanks for the Response!
It was very helpful, I made a slight tweak and now it works exactly as it should.
Here is what I put in my controller:
public class ViewAllIncidents { public ViewAllIncidents() { this.theIncidents = [SELECT c.Account.Name, c.CaseNumber, c.Status, c.due_date__c, c.subject, c.Contact.Email, c.description, c.Contact.Phone, c.Contact.Name FROM Case c WHERE c.AccountId = :ApexPages.currentPage().getParameters().get('acctId')]; } public List<Case> theIncidents { get; set; } public string aId = apexpages.currentpage().getParameters().get('acctid'); public PageReference cancel() { //cancel method to return to the account detail page return new PageReference('/'+ aId); } }