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
krishnagkrishnag 

populating the data on VF page2 based on parameters we gave on page 1

hi friends,

 

I am trying to create a webpage for the guest users  where they can edit their details whenever they want without entering into salesforce. So i created a custom login page for the users where user enters user id and email which are stored on Lead object prior. So it checks for the userid and email if they are true the user should be navigated to the second page where i have listed some lead fields as inputfields. 

 

so my target is when the user logins in  in the second page the Lead fields should be prepopulated based on the userid and email that havebeen mentioned by user in the first page.

 

Cab anybody help me in building the logic for prepopulating those fields.

 

 

Best Answer chosen by Admin (Salesforce Developers) 
krishnagkrishnag

found the solution for the problem we can write controler extension class to populate the data 

 

 

 

public with sharing class preference 
{
    string leadid;
    public Lead led{get;set;}
    public preference(ApexPages.StandardController controller)
    {
        // get the id of the quote and store it in quoteid
        this.leadid=ApexPages.currentPage().getParameters().get('paramID');   
        if(leadid!=null||leadid!='')
        {
            getdetails(leadid); 
        }    
    }
    public void getdetails(string leadid)
    {
        List<Lead> leads=[select id,User_Id__c,Email,Phone,Title,HasOptedOutOfEmail,A_H_Interest__c,Aftermarket_Interest__c,Construction_Interest__c,D_O_Interest__c,Energy_Interest__c,Environmental_Interest__c,Financial_Enterprises_Interest__c,Healthcare_Interest__c,Manufacturing_Interest__c,Property_Interest__c,Real_Estate_Interest__c,Technology_Interest__c,Windstorm_Notification__c from Lead where Id=: leadid];
        if(leads.size()>0)
        {
            led=leads[0];
        }
        else
        {
            
        }
    }
    public void savedtls()
    {
        Lead l=led;
        update l;
    }
}

 

public with sharing class preference {    string leadid; 

   public Lead led{get;set;}  

 public preference(ApexPages.StandardController controller)

    {        // get the id of the quote and store it in quoteid        this.leadid=ApexPages.currentPage().getParameters().get('paramID');         

 if(leadid!=null||leadid!='')        {            

getdetails(leadid);         }        

}    

public void getdetails(string leadid)    

{        List<Lead> leads=[select id,User_Id__c,Email,Phone,Title,HasOptedOutOfEmail,A_H_Interest__c,Aftermarket_Interest__c,Construction_Interest__c,D_O_Interest__c,Energy_Interest__c,Environmental_Interest__c,Financial_Enterprises_Interest__c,Healthcare_Interest__c,Manufacturing_Interest__c,Property_Interest__c,Real_Estate_Interest__c,Technology_Interest__c,Windstorm_Notification__c from Lead where Id=: leadid];

        if(leads.size()>0)      

 {            led=leads[0];        

}        else      

 {                    }    }    

public void savedtls()    {        

Lead l=led;        

update l;    }}

All Answers

Shilpa_SFShilpa_SF

Hi,

 

   Please refer to the below post, wher you can find information on passing parameters from one visualforce page to another visualforce page.

 

http://forums.sforce.com/t5/Visualforce-Development/Communication-between-controllers-on-the-same-page/m-p/84515

krishnagkrishnag

hi thanks for your reply but my problem is totally a different case.

krishnagkrishnag

found the solution for the problem we can write controler extension class to populate the data 

 

 

 

public with sharing class preference 
{
    string leadid;
    public Lead led{get;set;}
    public preference(ApexPages.StandardController controller)
    {
        // get the id of the quote and store it in quoteid
        this.leadid=ApexPages.currentPage().getParameters().get('paramID');   
        if(leadid!=null||leadid!='')
        {
            getdetails(leadid); 
        }    
    }
    public void getdetails(string leadid)
    {
        List<Lead> leads=[select id,User_Id__c,Email,Phone,Title,HasOptedOutOfEmail,A_H_Interest__c,Aftermarket_Interest__c,Construction_Interest__c,D_O_Interest__c,Energy_Interest__c,Environmental_Interest__c,Financial_Enterprises_Interest__c,Healthcare_Interest__c,Manufacturing_Interest__c,Property_Interest__c,Real_Estate_Interest__c,Technology_Interest__c,Windstorm_Notification__c from Lead where Id=: leadid];
        if(leads.size()>0)
        {
            led=leads[0];
        }
        else
        {
            
        }
    }
    public void savedtls()
    {
        Lead l=led;
        update l;
    }
}

 

public with sharing class preference {    string leadid; 

   public Lead led{get;set;}  

 public preference(ApexPages.StandardController controller)

    {        // get the id of the quote and store it in quoteid        this.leadid=ApexPages.currentPage().getParameters().get('paramID');         

 if(leadid!=null||leadid!='')        {            

getdetails(leadid);         }        

}    

public void getdetails(string leadid)    

{        List<Lead> leads=[select id,User_Id__c,Email,Phone,Title,HasOptedOutOfEmail,A_H_Interest__c,Aftermarket_Interest__c,Construction_Interest__c,D_O_Interest__c,Energy_Interest__c,Environmental_Interest__c,Financial_Enterprises_Interest__c,Healthcare_Interest__c,Manufacturing_Interest__c,Property_Interest__c,Real_Estate_Interest__c,Technology_Interest__c,Windstorm_Notification__c from Lead where Id=: leadid];

        if(leads.size()>0)      

 {            led=leads[0];        

}        else      

 {                    }    }    

public void savedtls()    {        

Lead l=led;        

update l;    }}

This was selected as the best answer