0

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;
    }
}
4
  • 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

0

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:pageBlockButtons>

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

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

    </apex:pageBlock>
</apex:form>
</apex:page>

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);
    pg.setRedirect(true);
    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 .