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
newbiewvfdevnewbiewvfdev 

How do you pass parameters from one page to another page?

Hi there,

 

I have a page, where I am displaying a record(i.e Job).  There are two buttons on the page. One is 'Copy Job' and 'Edit Job'. When a user clicks 'Copy Job', I have an action method on the custom controller called copyJob and I am copying the existing Job. Now I need to pass this job object to another page, which has a different controller.  How can I pass an object (i.e Job) from one page's controller to another page? Thank You.

 

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

You need to add the object id to the request. 

 

Presumably your action method is returning a pagereference?

 

In which case, you need something like the following:

 

PageReference pr=Page.MyPage;

pr.getParameters().put('id', <the new object id>);

 

return pr;

 

This assumes you are using a standard controller plus extensions, or are picking up the object id in a custom controller.

All Answers

bob_buzzardbob_buzzard

You need to add the object id to the request. 

 

Presumably your action method is returning a pagereference?

 

In which case, you need something like the following:

 

PageReference pr=Page.MyPage;

pr.getParameters().put('id', <the new object id>);

 

return pr;

 

This assumes you are using a standard controller plus extensions, or are picking up the object id in a custom controller.

This was selected as the best answer
newbiewvfdevnewbiewvfdev

Hi,

 

Does this mean you could only pass an id to another page?  You can't pass the object or an object reference to the other page?

bob_buzzardbob_buzzard
I'm not aware of any way you can pass the object/object reference between pages.