I need to call the VF page with edit and save buttons and display the lead values from the code in VF page.

public class GetLeadfromUrl {    
    public static void GetDownloadUrl(String url) {
        //. from the URL i will get the lead details.
        ////  few code is there////
        Lead l = new Lead();
        l.Phone = '12345646';
        l.Email = '[email protected]';
        l.Company = 'Infotech';
        // before creating into lead i need to display the VF page to display the lead details
        insert l;
  • You mean before inserting lead entered values must be display in vf page for get confirmation ?
    – Nihar
    Jun 15, 2017 at 9:42
  • yes you are correct
    – Mahesh
    Jun 15, 2017 at 9:43
  • Ok then you need queryString here
    – Nihar
    Jun 15, 2017 at 9:44
  • not sure , i am new to SF . can you please provide me sample code
    – Mahesh
    Jun 15, 2017 at 9:47

1 Answer 1


See this link for queryString and how it's useful for us : Getting Query String Parameters

Look into below code it seems you can get some idea, it is fully customized with visualforce page and apex class :

Visualforce page

<apex:page controller="AccountConfirmINsertController">
<apex:form >
    <apex:pageBlock >

        <apex:pageBlockButtons >
            <apex:commandButton value="Confirm" action="{!Confirm}" rendered="{!accountName == Null}"/>
            <apex:commandButton value="Save" action="{!Save}" rendered="{!accountName != Null}"/>
            <apex:commandButton value="Cancel" action="/apex/AccountConfirmINsert"/>

        <apex:pageBlockSection >
            <apex:inputField value="{!account.Name}" rendered="{!accountName == Null}">
                <apex:param value="{!account.Name}" name="Name"/>
            <apex:inputField value="{!account.date__c}" rendered="{!accountName == Null}">
                <apex:param value="{!account.date__c}" name="date"/>

        <apex:pageBlockSection >
            <apex:outputText value="{!accountName}" label="Account Name" rendered="{!accountName != Null}"/>
            <apex:outputText value="{!accountdate}" label="Account Date" rendered="{!accountName != Null}"/>


Apex class

public class AccountConfirmINsertController{

public Account account{get;set;}
public string accountName{get;set;}
public string accountdate{get;set;}

public AccountConfirmINsertController(){
    account = new Account();
    accountName = ApexPages.currentPage().getParameters().get('Name');
    accountdate = ApexPages.currentPage().getParameters().get('date');

public pagereference confirm(){

    Pagereference pg = new Pagereference('/apex/AccountConfirmINsert?Name='+account.Name+'&date='+account.date__c);
    return pg;


public pagereference Save(){

    account.Name = accountName;
    account.date__c = Date.ValueOf(accountdate);
    insert account;

    return new Pagereference('/'+account.Id);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .