5

Hi I sent my entire code

VF Page: DEMO

   <apex:form >
      <apex:pageBlock >
           <apex:commandButton value="Call visualforce Page" action="{!click}"/>
      </apex:pageBlock>
 </apex:form>

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 = '0019000000NAracffo';//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 attached the Account Object under the one section.Please see the screen short enter image description here

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 but I am unable to get the current Account Id only?Please let me know as soon as possible......

Best Regards, Ramesh

3

You could do it in here you click method:

public class NewAndExistingController {
    Account acc = NEW Account();    
    public PageReference click() { 
        PageReference openvfpage = New Pagereference('/apex'+'/XYZ');   
        openvfpage.getParameters().put('account',yourAccountVar);
        openvfpage.setRedirect(false);
        return openvfpage ;         
    }   
    public NewAndExistingController() {    }  
}

Then, in the receiving VF page, you would get it through:

String var = ApexPages.currentPage().getParameters().get('account');
0

you can set parameter to the url and get it...

Please refer this link...

http://www.salesforce.com/us/developer/docs/pages/index_Left.htm#StartTopic=Content/pages_quick_start_query_params.htm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.