You need to sign in to do that
Don't have an account?
BAR
Custom button -- how to include return URL
I have created a custom button that calls a VF page 'CreateClasses' --> /apex/CreateClasses?id={!Campaign.Id}
This button resides on the page for a particular Campaign record type. When I select the Cancel button on the CreateClasses page, I want to return to this same page.
How can I include the retURL parameters in the custom button (without hard-coding the entire URL)? Is there any way to capture the $CurrentPage.Name from the original/calling page?
Thanks,
Barb Ryan
I actually found another solution that worked --- it was written by Wes as follows:
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
On the Cancel button you must be calling some function try the following :-
PageReference pageRef = new PageReference('<partialURL>');
Set partialURL to '/' + <recordID>
Here <recordID>= newOpp.id;
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
Hey
Make your custom button hit this URL instead,
/apex/CreateClass?id{!Campaign.id}&retUrl={!$CurrentPage.Url}
And on the 'CreateClass' page put the following in your cancel button,
{!$CurrentPage.parameters.retUrl}
Cheers,
Wes
I actually found another solution that worked --- it was written by Wes as follows:
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
If your button is Javascript, you should be able to use..
encodeURIComponent(window.location.href);