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
Roger PavelleRoger Pavelle 

Issue passing ID from one custom form to another.

I have two VisualForce pages that I've created that deal with a custom object.  The first page has several search criteria.  The second page is called from the first and is designed to show the details of a selected record.

How do I pass the ID from the Search page to the Detail page?  The code snippit I'm using is:
                        <apex:outputLink value="{! URLFOR('/apex/boleteDetailView', bol.Id) }">
                            View
                        </apex:outputLink>
This opens the detail page fine, but I don't see any evidence that the ID has been passed.

I've also tried creating a function in the controller that would hold the ID (so I could get around this problem), but that doesn't seem to work either (probably due to a misunderstanding of the way the apex:outputLink tag works).
                        <apex:outputLink value="{! URLFOR('/apex/boleteDetailView', bol.Id) }">
                            <apex:actionSupport action="{!setSelectedID}" event="onclick">
                                <apex:param name="ID" value="{!bol.ID}"/>
                            </apex:actionSupport>
                            View
                        </apex:outputLink>


Also, once I am on the detail page, how do I retrieve the details for the selected record?  Is there a way to retrieve the custom object's fields/values directly (like you can with the standard controller) or will I also need to create a function in the custom controller to get the detail records?
Best Answer chosen by Roger Pavelle
Amit Chaudhary 8Amit Chaudhary 8
Please try to use only below code:-
<apex:outputLink value="/apex/boleteDetailView?id={!bol.Id}">
                            View
</apex:outputLink>

Then use below code. To get Id in boleteDetailView controller. 
String strId = ApexPages.currentPage().getParameters().get('Id');

Please let us know if this will help you.

Thanks,
Amit Chaudhary

All Answers

NagaNaga (Salesforce Developers) 
Hi Rojer,

Please see the sample code below

User-added imageplease see the link below

https://developer.salesforce.com/forums/?id=906F0000000An8iIAC

Best Regards
Naga Kiran
Chamil MadusankaChamil Madusanka

You need to implement this scenario using Visualforce wizard.

Refer this link: http://developer.force.com/cookbook/recipe/creating-a-wizard-with-visualforce-pages

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_quick_start_wizard.htm

If you get the answer, please mark it as the correct answer. It will be a help to others who are facing the same problem later.
Roger PavelleRoger Pavelle
Thanks.  This code does pass the ID to the detail page, but it is not passing the value to the controller (the action support is not working).

So, since the ID is being passed to the detail page, is there a way to retrieve the value from there and then pass it to the controller or access it from the controller?  I've tried using ApexPages.currentPage().getParameters().get('Id') in the controller, but it is not retrieving anything (i.e. value is null).
Amit Chaudhary 8Amit Chaudhary 8
Please try to use only below code:-
<apex:outputLink value="/apex/boleteDetailView?id={!bol.Id}">
                            View
</apex:outputLink>

Then use below code. To get Id in boleteDetailView controller. 
String strId = ApexPages.currentPage().getParameters().get('Id');

Please let us know if this will help you.

Thanks,
Amit Chaudhary
This was selected as the best answer
Roger PavelleRoger Pavelle
Thanks.  That's working great.