Hi I sent my entire code
VF Page: DEMO
<apex:page controller="NewAndExistingController" >
<apex:form >
<apex:pageBlock >
<apex:commandButton value="Call visualforce Page" action="{!click}"/>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller:NewAndExistingController
public class NewAndExistingController {
Account acc = NEW Account();
public PageReference click() {
PageReference openvfpage = New Pagereference('/apex'+'/XYZ');
openvfpage.setRedirect(false);
return openvfpage ;
}
public NewAndExistingController() { }
}
VF Page:XYZ
<apex:page standardController="Order__c" extensions="MyOrderPadController" >
<apex:detail />
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save"/>
<apex:commandButton action="{!edit}" value="Edit"/>
</apex:pageBlockButtons>
<apex:pageBlockSection columns="2" title="Order Pad">
<apex:inputField value="{!Order__c.Order_Description__c}" />
<apex:inputField value="{!Order__c.Creat_Date__c}" />
<apex:inputField value="{!Order__c.Closed_Date__c}" />
<apex:inputField value="{!Order__c.Conformation__c}" />
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller:MyOrderPadController
public class MyOrderPadController {
public Order__c order{
get; private set;
}
public MyOrderPadController(ApexPages.StandardController sc){
order = (Order__c)sc.getRecord();
}
public PageReference save(){
order.Account__c = '0019000000NAr7bAAD';//for testing only
IF(order.Conformation__c == TRUE){
INSERT order;
PageReference newpage = new PageReference(System.currentPageReference().getURL());
newpage.setRedirect(true);
return newpage;
}
return null;
}
}
Here DEMO VF page attched the Account Object under the one section.it show like see the screen short
When ever user click the "Call visualforce Page" button then go to XYZ VF page,In this page how to get the current Account Id and how to pass Account Id to "MyOrderPadController".As of now Account id is hard coded how to get account id?
the above code is working as accepted or I have implemt wroung way Please let me know as soon as possible