Hey guys, today in this post we are going to learn about How to Pass Record Id into Visualforce page to display the record of current Account calling extension method of apex class in visualforce Salesforce.
Visualforce includes nearly 150 built-in components that you can use on your pages. Components are rendered into HTML, CSS, and JavaScript when a page is requested. Coarse-grained components provide a significant amount of functionality in a single component, and might add a lot of information and user interface to the page it’s used on. Fine-grained components provide more focused functionality, and enable you to design the page to look and behave the way you want. To get more details about Display Records, Fields, and Tables in Visualforce, Click Here.
Final Output →
You can download file directly from github by Click Here.
Other related post that would you like to learn in Salesforce
- Find the below steps â–¾
Step 1:- Create Visualforce Page : SalesAccountOrderFormPDFvFP.vfp
From Developer Console >> File >> New >> Visualforce Page
SalesAccountOrderFormPDFvFP.vfp [Component Visualforce Page]
<apex:page applyHtmlTag="false" showHeader="false" standardController="Account" extensions="SalesAccountOrderForm_Controller" renderAs="pdf" standardStylesheets="false"
applyBodyTag="false">
<head>
<style>
@page {
size: A4 portrait;
margin: 3mm;
}
body {
font-family: sans-serif;
font-size: 11pt;
}
th {
min-height: 15px;
max-height: auto;
background:#ddd;
}
td {
min-height: 15px;
max-height: auto;
}
</style>
</head>
<body>
<table border="1" cellspacing="0" cellpadding="10" style="width: 100%; border-collapse: collapse; border-color: #000; text-align:left;">
<thead>
<tr>
<th>Name</th>
<th>Phone</th>
<th>Industry</th>
<th>Rating</th>
<th>Description</th>
<th>Website</th>
</tr>
</thead>
<apex:repeat value="{!accObj}" var="accItem">
<tr width="100%" style="text-align: center;">
<td style="text-align:left;"><apex:outputText value="{!accItem.Name}"/></td>
<td style="text-align:left;"><apex:outputText value="{!accItem.Phone}"/></td>
<td style="text-align:left;"><apex:outputText value="{!accItem.Industry}"/></td>
<td style="text-align:left;"><apex:outputText value="{!accItem.Rating}"/></td>
<td style="text-align:left;"><apex:outputText value="{!accItem.Description}"/></td>
<td style="text-align:left;"><apex:outputText value="{!accItem.Website}"/></td>
</tr>
<apex:repeat value="{!accItem.Contacts}" var="con">
<tr width="100%" style="text-align: center;">
<td style="text-align:left;"><apex:outputText value="{!con.Name}"/></td>
<td style="text-align:left;"><apex:outputText value="{!con.FirstName}"/></td>
<td style="text-align:left;"><apex:outputText value="{!con.LastName}"/></td>
<td style="text-align:left;"><apex:outputText value="{!con.Email}"/></td>
<td style="text-align:left;"><apex:outputText value="{!con.Phone}"/></td>
<td style="text-align:left;"><apex:outputText value="{!con.Title}"/></td>
</tr>
</apex:repeat>
</apex:repeat>
</table>
</body>
</apex:page>
Create Apex Class Controller Extension of Visualforce
Step 2:- Create Apex Class : SalesAccountOrderForm_Controller.apxc
As per student's demands, I re-opened my eBook of "Salesforce Tutorial" Limited-time huge discount offer Absolutely 50% Off.
I am thinking to give you discount offer occasion of Gandhi Jayanti for a powerful "Salesforce admin course" where you can Understand from Basic Concepts to advanced label in Salesforce.
👉 So Don't MISS it... (Access Right Now)
👉 Get Huge Discount Offer 50%: - Get eBook
From Developer Console >> File >> New >> Apex Class
SalesAccountOrderForm_Controller.apxc [Apex Class Controller]
public class SalesAccountOrderForm_Controller {
public String MstrId{GET;SET;}
public Account accObj{GET;SET;}
public SalesAccountOrderForm_Controller(ApexPages.StandardController Controller){
MstrId = ApexPages.currentPage().getParameters().get('id');
accObj = [SELECT Id, Name, Phone, Industry, Rating, Description, Website, TYPE, (SELECT Id, Name, FirstName, LastName, Email, AccountId, Phone, Title FROM Contacts) FROM Account WHERE Id =: MstrId ];
}
}
Further post that would you like to learn in Salesforce
How do I find the record id of a VF page?
currentPage(). getParameters(). get('id'); The above line will get id URL parameter from browser URL and set into your declared variable 'RecordId'.
How can I get Object name from record ID?
Execute the following snippet of code in the Developer Console to find the Object name based on the Record ID prefix: String objectName = SchemaGlobalDescribe. findObjectNameFromRecordIdPrefix('500'); System. debug(objectName);
How do you pass ID from Visualforce pages to the apex class?
In vf page, add the id as paramater in URL and retrieve in method1 in apex using ApexPages. currentPage(). getParameters(). get('id'), where id is parameter name.
Related Topics | You May Also Like
- My Udemy Course →



