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
risharisha 

how to get lists from 4 different unrelated sobject in one pageblocktable

how to get lists from 4 different unrelated sobject in one pageblocktable.pls help me

Vinita_SFDCVinita_SFDC

Hello Risha,

Create a custom controller and in it retrieve objects. For two objects you can access as follows:

<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;
          insert myB;
     }
}

If you wish to represent data in table then you can refer following link:

http://salesforce.stackexchange.com/questions/6184/display-repeated-data-in-table-from-two-different-unrelated-objects

KamsR_DEVKamsR_DEV

Hi,

 

In a PageBlockTable you cannot get the different and unrelated lists of values. But, this can be accheive using Html table.

 

For eg, you can query different unrelated objects records and assign those values to a property or variables.

 

Example:

***********

VF page,

---------------

<apex:page controller="listcon">
<apex:form>

<table>

<tr>

<th>A</th>
<th>B</th>
<th>C</th>

<th>D</th>

</tr>

 

<tr>

<td><apex:inputfield value="{!a}"></td>
<td><apex:inputfield value="{!b}"></td>
<td><apex:inputfield value="{!c}"></td>

<td><apex:inputfield value="{!d}"></td>

</tr>

</apex:form>

</apex:page>

 

Controller,

---------------

public class listcon{

 

public string a{get;set;}

public string b{get;set;}

public string c{get;set;}

public string d{get;set;}

 

public listcon(){

   A__c a1 = [select id,name from A__c where name="aa" limit 1];

   B__c b1 = [select id,name from B__c where name="bb" limit 1];

   C__c c1 = [select id,name from C__c where name="cc" limit 1];

   D__c d1 = [select id,name from D__c where name="dd" limit 1];

 

  a = a1.name;

  b = b1.name;

  c = c1.name;

  d = d1.name;

}

 

}

 

So, your output will be as a table. you can design the HTML table after doing the logics.

 

Hope, this will help you....!