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
Admin User 10568Admin User 10568 

Access Records with Object IDs

Hi, 

I would like to Access Records with object IDs within a visualpage with a custom controller. The use case is: User hits button, renders the visualforce page and it renders data relating to the object they're on. 

The current code doesn't require an object ID to render. It renders everything. 

See page below:

<apex:page Controller="PriceListAscending" renderAs="pdf" showHeader="false" >

    <apex:pageBlock >
     
          <apex:pageBlockTable value="{!Events}" var="e" align="center" cellpadding="2" style="font-weight: bold">
               <apex:column value="{!e.name} {!e.REPRO__Street__c} {!e.REPRO__City__c}" style= "text-align: center;"/>
         </apex:pageBlockTable>
             <apex:pageBlockTable value="{!Events}" var="e" align="center" cellpadding="2" style="font-weight: bold">
        <apex:column value="{! TODAY()}" style= "text-align: center;" />
              </apex:pageBlockTable>
   
    <apex:pageBlockTable value="{!Events}" var="e">
<apex:column >
        <apex:pageBlockTable value="{!e.REPRO__Properties__r}" var="custom" align="center" cellpadding="2" border="2"  style="font-weight: bold; text-align: center; ">
              <apex:column value="{!custom.Property_Level__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
              <apex:column value="{!custom.Price_List_Property_Name__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
              <apex:column value="{!custom.REPRO__Type__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />   
              <apex:column value="{!custom.REPRO__Bdr__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
              <apex:column value="{!custom.REPRO__Bth__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
              <apex:column value="{!custom.REPRO__Study__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
              <apex:column value="{!custom.REPRO__Internal_Size__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; "  />
              <apex:column value="{!custom.REPRO__External_Size__c}"  style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
              <apex:column value="{!custom.REPRO__Car__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
              <apex:column value="{!custom.REPRO__List_Price__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
              <apex:column value="{!custom.REPRO__Status__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
            </apex:pageBlockTable>
    </apex:column>
        </apex:pageBlockTable>
           
Any help would be great. The trailhead examples do this with the standard controller.
 
Best Answer chosen by Admin User 10568
Admin User 10568Admin User 10568
Hi @Shirisha, 

Hope you're well. 

Thank you for your response.

The URL directs to an article about adding a button to an apex page.

I have now created a custom button on the object layout that displays a visual page. The issue I was having was in regards to controllers. It seems a visual page saved with a custom controller is not available as content for a custom button. Since, I have used the standard controller with a controller extension to achieve list ordering. This was available for use and the button renders the visual force page as anticipated.

Thanks again for your help. Apologies, it's likely my question wasn't well put.

All the best.

All Answers

ShirishaShirisha (Salesforce Developers) 
Hi,

Greetings!

Please find the sample code in the below thread for the reference:

https://salesforce.stackexchange.com/questions/154677/retrieve-and-display-records-of-a-custom-object-on-click-of-a-button

Please mark it as best answer if it helps you to fix the issue.

Thank you!

Regards,
Shirisha Pathuri
Admin User 10568Admin User 10568
Hi @Shirisha, 

Hope you're well. 

Thank you for your response.

The URL directs to an article about adding a button to an apex page.

I have now created a custom button on the object layout that displays a visual page. The issue I was having was in regards to controllers. It seems a visual page saved with a custom controller is not available as content for a custom button. Since, I have used the standard controller with a controller extension to achieve list ordering. This was available for use and the button renders the visual force page as anticipated.

Thanks again for your help. Apologies, it's likely my question wasn't well put.

All the best.
This was selected as the best answer