ads

Thursday, 28 July 2016

Insert Record And Redirect To Detail Page



Controller Code :-

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
public class TransferIDtoNextPage
{
public Account Accinsert{get;set;}

 public pagereference save()
    {
        insert accinsert;
        
        Pagereference page=new Pagereference('/'+accinsert.id);
        Page.setredirect(true);
        return page;
    }

public TransferIDtoNextPage()
    {
    Accinsert=new account();
    
    
    }

}

Visualforce Page Code :-


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<apex:page controller="TransferIDtoNextPage">
<apex:form >
<apex:pageBlock >

<apex:pageBlockButtons >
  <apex:commandButton action="{!save}" value="Save"/>
 </apex:pageBlockButtons>
 
<apex:pageblockSection >


<apex:inputField value="{!accinsert.name}"/>
<apex:inputField value="{!accinsert.type}"/>
<apex:inputField value="{!accinsert.phone}"/>



</apex:pageblockSection>


</apex:pageBlock>

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

Output Screen :-

    1st Screen :- VF Page To Fill Value


    2nd Screen :- Detail Page Of Recently Inserted Record.




No comments:

Post a Comment