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
iKnowSFDCiKnowSFDC 

Passing VisualForce Page Parameters from one page to the next

On a visualForce page, I'm showing a list of records belonging to the user as well as a list of records that haven't been claimed as of yet.  On the first page, I'm identifying the user by the id in the URL.  When they claim a record, I am passing them to a page that shows the record details and a confirmation button.  

 

When I get to that second page, I'm losing the connection to the user and I'm not sure how to pass that over to the second page.  

 

Here is the controller code:  

 

public list<Lead> getLeads2beClaimed() {
    	
leads2beClaimed = [SELECT id, FirstName, LastName, Phone, Email, Street, City, State, PostalCode, Country,Company,                        claimant__c, Claimant__c.Id, Status, Lead_Number__c, Claimant.email, LeadSource, Job_Role__c 
FROM Lead WHERE Claimaint__c = NULL];

return leads2beClaimed; 
    
  }
    
public pageReference slctLead2beClaimed(){
        l2bclaimed = [SELECT id, Name, Claimant__c, Claimant__r.Email
                FROM Lead WHERE id = :ApexPages.currentPage().getParameters().get('claimID')];

        l2bclaimed.Claimant__c = claimUser.id;
 
        update l2bclaimed;
        pageReference updtdLead = new pageReference('/apex/claimLeads?id='+claimUser.id);
        updtdLead.setRedirect(true);
    return updtdLead;
   }
  

 Thethis is the VF code I"m using to select the lead and pass them to the confirmation page: 

<apex:form >
<apex:pageBlock title="Leads to be Claimed">
    <apex:pageBlockTable value="{!l2bclaimed}" var="st" rows="10" width="500px" > 
        <apex:column headerValue="Company" >
            <apex:outputField value="{!st.Company}"/> 
        </apex:column>
        <apex:column headerValue="City" >
            <apex:outputField value="{!st.City}"/> 
        </apex:column>
        <apex:column headerValue="State" >
            <apex:outputField value="{!st.State}"/> 
        </apex:column>        
        <apex:column headerValue="Job Role" >
            <apex:outputField value="{!st.Job_Role__c}"/> 
         </apex:column>        
		 <apex:column headerValue="Select (up to 5/day)">
		 	<a href="/apex/claimLeads?id={!st.Claimant__r.email}&claimId?={!st.id}">Select</a>
        </apex:column> 
     </apex:pageBlockTable>
</apex:pageBlock>
</apex:form>

 

I'm getting the following error after clicking the select button on the Claim Leads page.  When I look at the URL for the ClaimLeads page, the email address is not being passed through on the URL.  I'm not sure how to pass it through when selecting the lead.  

 

System.NullPointerException: Attempt to de-reference a null object

 

Class.partnerView.slctLead2beClaimed: line 111, column 1     

 

 

The other thing I should note is that I orignally had this set to not go to the confirmation page but in stead to automatically be connected to the user and to show in a list of claimed leads on the same page - however - the <apex:commandLInk> I had to select the leads was taking the first lead in the list as opposed to the lead actually being selected.  I would rather not have the iterim step, but am unsure how to pass the id of the lead in the list through to the controller so it's the one being updated instead of the first one on the list.  

 

Thank you for your help.  

 

JoAnn

Best Answer chosen by Admin (Salesforce Developers) 
iKnowSFDCiKnowSFDC

Turned out to be two issues: 

 

1.  I didn't have a getter method, once I put that in, it worked like a charm and solved another problem I hadn't tackled yet. (duh!) 

2.  I was specifying the link incorrectly - (thanks to @SeAlVa_VFTabulator for pointing that out). 

 

Thanks for all the great suggestions.  

 

@Claiborne - I think on the next project I will go the outputPanel route - I hadn't even considered that.  

 

@tric - thanks for the wizard suggestion.  I did consider that - but it wasn't quite right for this application. I've used wizards successfully in other applications and have another part of this application that I think a wizrd will be the right solution. 

 

Thanks again for all the great suggestions!

 

JoAnn

All Answers

SeAlVa_VFTabulatorSeAlVa_VFTabulator

Instead of 

<a href="/apex/claimLeads?id={!st.Claimant__r.email}&claimId?={!st.id}">Select</a>

 Try

<a href="/apex/claimLeads?id={!st.Claimant__r.email}&claimId={!st.id}">Select</a>

 

(Without the extra '?' )

 

Regards

iKnowSFDCiKnowSFDC

Thanks, but that doesn't actually solve my problem with the id of the claimant not being pass over in the URL so am still getting the same error.  

SeAlVa_VFTabulatorSeAlVa_VFTabulator

what is your line 111?

iKnowSFDCiKnowSFDC

Line 111 is return leads2beClaimed; which is part of the getLeads2beClaimed() method.

 

 

trictric

Hi ,

 

Please try to look at the opporunity wizard  example in the salesforce developer guide where they are sharing information from page to page.

 

That might help you.

 

 

Thanks,

Tric

ClaiborneClaiborne

There are two ways to keep parameters within a "wizard" as you move from page to page.

 

1. Keep going back to the same page, but display different parts of the page at different times with output panels and rendered logic. 

<apex:page>
<apex:outputPanel name="page1" rendered={!isPage1}">
  -- Stuff for page 1 --
</apex:outputPanel>
<apex:outputPanel name="page2" rendered={!isPage2}">
  -- Stuff for page 2 -- 
</apex:outputPanel>

 In this method, isPage1 and isPage are public Boolean variables in your controller. In your "action" methods, set these values appropriately.

 

2. Use separate pages, but have them use  the same apex controller. As long as the controller is the same, the controller variables are preserved as you move from page to page.

iKnowSFDCiKnowSFDC

Turned out to be two issues: 

 

1.  I didn't have a getter method, once I put that in, it worked like a charm and solved another problem I hadn't tackled yet. (duh!) 

2.  I was specifying the link incorrectly - (thanks to @SeAlVa_VFTabulator for pointing that out). 

 

Thanks for all the great suggestions.  

 

@Claiborne - I think on the next project I will go the outputPanel route - I hadn't even considered that.  

 

@tric - thanks for the wizard suggestion.  I did consider that - but it wasn't quite right for this application. I've used wizards successfully in other applications and have another part of this application that I think a wizrd will be the right solution. 

 

Thanks again for all the great suggestions!

 

JoAnn

This was selected as the best answer
robert leveckrobert leveck
I just need a way to navigate from one lead to the next without having to go back to the top of the lead list after I disposition each lead.