function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
alockremalockrem 

How to dynamically set the PageReference based on the previous page

I have a custom object to hold site records (site__c).  In the process of working through a collection of Visual Force pages I want to provide the option for a user to quickly add a site and then continue with the process they are currently on.

 

Example:

1) User creates a new opportunity (id=000000001)

2) User clicks "Add Product Wizard" which launches /apex/AddProdWiz?id=000000001

3) User is prompted to select a site from the list of existing sites (associated at an account level)

4) If the site isn't listed the user should click "Add a site"

 

Here is where I need help.  I want the user to complete the same form displayed when the user accesses the site__c object and clicks "new".  I also want them to be returned to /apex/AddProdWiz?id=000000001 when he/she is done adding the site.  Ideally, I would like the user to be returned to /apex/AddProdWiz?id=000000001&siteID=000000002 so I can automatically select the newly added site.

 

Should I be sending the user to a Visual Force page that uses a standardController="site__c"?  If so, how do I tell it to display the add form on the screen?

 

Thank you for your help.

SPDSPD

Im not sure about whether this works in your case....but it worked for me when i tried doing it for an custom EDIT button

 

/e?retURL=/apex/AddProdWiz?id=00000001

 

 

you will need to override the NEW button and call a method in your apex class. the method will be of type pagerefernce...and you will need to give the above url.

alockremalockrem

That worked for the example I provided.  When I  added the additional querystring parameters the functionality didn't work as well.  It appears SalesForce.com didn't know if my additional querystring parameters were supposed to be interpreted by the site screen or appended to the retURL parameter.

 

Either way, I've realized the additional flags I need to set when an edit is completed will be easier to manage on a Visual Force page.  I've been told it is easy to embed the edit portion of an object on a Visual Force page, but I can't find any reference of how to do it.

 

Any help is greatly appreciated.