I've read many suggestions regarding retrieving values from sObject in controllers and classes. I want to know if I can retrieve a specific field value from an sObject (which could be an Account in one instance, contact in another, or even a custom object in another, etc). For this example, I want to retrieve the Name field. The sObject in this case is an Account.

The snippit of coding giving me issues is:


in the following line of code:

<apex:param name="rowIndex" assignTo="{!SAN}" value="{!sObj.Name}"/>

The error I receive is as follows: Error: Unknown property 'SObject.Name'

In the debug logs, it clearly shows that the object has the Name attribute, but since it seems to be an sObject I am unable to access it. I have tried to paste as minimal code as possible. If there is any confusion, please let me know.


<!-- Attributes to accept the parameters -->
<apex:attribute name="Records" Type="sObject[]" assignTo="{!sObjLst}" required="true" description="Accepts list of records of any object and assign to a variable in controller class"/>
<apex:attribute name="Fields" Type="String[]" required="true" description="Accepts list of field API names of a sobject in string format"/>
<apex:attribute name="Title" Type="String" required="true" description="Accepts the title of the section"/>
<apex:attribute name="IsActionColumnEnabled" Type="Boolean" required="true" description="Determines whether action column should be displayed in table"/>
<apex:attribute name="Buttons" Type="List" required="false" description="Buttons for column"/>
<apex:attribute name="URLs" Type="List" required="false" description="URLs for buttons"/>

<apex:pageBlockTable value="{!sObjRecords}" var="sObj" styleClass="dataTable" id="pageBlockTable">

    <!-- Dispalys the multiple columns based on the user input -->
    <apex:repeat value="{!Fields}" var="fld">
        <apex:column value="{!sObj[fld]}"/>

        <!-- Action Column with buttons - May not applicable for all pages -->
        <apex:column rendered="{!IsActionColumnEnabled}" >
            <apex:facet name="header">{!$Label.YAHS_PRT_Action}</apex:facet>
                <apex:repeat value="{!Buttons}" var="button">
                    <apex:commandButton value="{!button}" Action="{!urlRedirection}" rerender="hiddenBlock" styleClass="btn btn-primary nbtn" >
                        <!-- Allows for retrieval of SAN for a given row where a button is pressed -->
                        <apex:param name="rowIndex" assignTo="{!SAN}" value="{!sObj.Name}"/>
                        <!-- Hidden pageBlock allows for the param above to be passed within a commandButton -->
                        <apex:pageBlock id="hiddenBlock" rendered="false"></apex:pageBlock>

Component Controller

//Stores the records which are supplied to the 'Records' attribute.
public Sobject[] sObjLst {get;set;}

1. Implementing the pagination with ApexPages.StandardSetController.
2. We can utilize the built in methods available for the ApexPages.StandardSetController to build the pagination.
3. Following are the built in mehods we can utilize -
a. first()
b. previous()
c. next()
d. last()
e. getHasPrevious() - returns boolean value.
f. getHasNext() - returns boolean value.
g. setPageSize(IntegerValue)

public ApexPages.StandardSetController con {
    get {
    //initializing con with the records.
    if(con == null)
        con = new ApexPages.StandardSetController(sObjLst);

    //Setting the pagination size

    return con;

//Method which returns subset of records from the sObjLst.
public List<sobject> getSobjRecords() {        
    //Type Casing the records and returning to display on the page.
    return (List<sobject>)con.getRecords();


VF Page

<c:GenericPaginationComponent Title="" records="{!locationAccLst}" fields="{!locationAccFieldLst}" IsActionColumnEnabled="true" Buttons="{!buttons}" URLs="{!endPointURL}"/>

VF Page Controller

//Querying the records from the database.
locationAccLst = [SELECT Name, ShippingAddress FROM Account limit 100];

//Preparing the list of fields to display in the table.
locationAccFieldLst = new List<String>{'Name', 'ShippingAddress'};

buttons = new List<String>{'Test Button1', 'Test Button2'};

1 Answer 1


I believe it should be:



  • Thank you for the suggestion. It works! I thought I tried this already, but I must have had something wrong with my syntax.
    – Kevin
    Commented Jun 22, 2016 at 14:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .