function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
padmapadma 

Field Access in apex Vf page

Hi ,
 There is a Two objects X,Y X  contains field  status  and Y  contains  a field Functional area . How can  we access  the both fields in
Apex Vf page .please help???
Thanks,
padma.
Vijay NagarathinamVijay Nagarathinam
Just use this code in your controller

public Object1 instance1{get;set;}
public Object2 instance2{get;set;}

VF page:

<apex:inputfield value="{!insatnce1.Fieldname}"/>
<apex:inputfield value="{!insatnce2.Fieldname}"/>

With the help of above code you can display the two object fields in your visualforce page.
 
sfdc550sfdc550
your VF Page
<apex:page controller="myController">
<apex:pageblock>
     <apex:pageblockButtons>
          <apex:commandButton value="Save" action="{!saveObjects}"/>
     <apex:pageblockButtons/>
     <apex:pageblocksection>
          <apex:inputfield value="{!myA__c.Name}"/>
          <!-- add any other fields you want for this object -->
     </apex:pageblocksection>

     <apex:pageblocksection>
          <apex:inputfield value="{!myB__C.Color__c}"/>
          <apex:inputfield value="{!myB__C.Location__c}"/>
     </apex:pageblocksection>

</apex:pageblock>
</apex:page>



Controller
 
public class myController{

     public ObjectA__c myA      {get;set;}
     public ObjectB__c myB      {get;set;}

     public myController(){
          myA = new ObjectA__c();
          myB = new ObjectB__c();
     }

     public void saveObjects(){
          insert myA;
          myB.ObjectA__c = myA.Id;
          insert myB;
     }

}