3

I have one VF page that contains custom fields.

Now I am trying to add the VF page to Account Object tab under a page section. If this is possible can someone explain me how ?

VF Page

<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:commandButton action="{!reset}" value="Cancel" />
            </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:

public class MyOrderPadController {
    public Order__c order{ get; private set; }
    ApexPages.StandardController controller;
    public MyOrderPadController(ApexPages.StandardController sc) {
    controller = sc;
     order = (Order__c)sc.getRecord();   
    }
public PageReference edit() 
     { 
           return null;        
     }
     public PageReference reset()
     {
          PageReference newpage = new PageReference(System.currentPageReference().getURL());
          newpage.setRedirect(true);
          return newpage;
    }
     public PageReference save() 
     {
          TRY
          {              
               order.Name = 'None';
                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;     
                    }


                    }   

The above code VF page and Controller How to add the VF page to Account object How to get the current account id in the VF page?

1
  • Ramesh - I moved the contents of your answers into the question to make it clearer what you're asking and make it easier for others to help you. Please take a look at the about page for how the Salesforce Stack Exchange format works. – Peter Knolle Dec 21 '13 at 14:14
2

Your VF page needs to use the standard controller for the account. Then you should be able to add it onto the page layout(s) for the object.

If you need an custom code you should add that to a extension controller. The record that your VF page is showing on is accessible in your controller by using

sObject rec = stdController.getRecord();

Where stdController is the parameter in the constructor of your extension controller. You do not need to pass anything to the VF page - it's handled automatically when the VF page is added to a page layout.

1
  • 1
    I think he's also asking how to put the vf page on the page layout. – Samuel De Rycke Dec 21 '13 at 9:32

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.