Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Pass Record Id into Visualforce page to display the record of current Account calling extension method of apex class in Visualforce Salesforce #4

Open
vijayk3327 opened this issue Sep 13, 2023 · 0 comments
Assignees
Labels
documentation Improvements or additions to documentation question Further information is requested

Comments

@vijayk3327
Copy link
Owner

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.

👉 Get source code live demo link:-

Step 1:- Create Visualforce Page : SalesAccountOrderFormPDFvFP.vfp

`<apex:page applyHtmlTag="false" showHeader="false" standardController="Account" extensions="SalesAccountOrderForm_Controller" renderAs="pdf" standardStylesheets="false"
applyBodyTag="false">

<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

`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 ];

}

}`

👉 Get source code live demo link:-

@vijayk3327 vijayk3327 added documentation Improvements or additions to documentation question Further information is requested labels Sep 13, 2023
@vijayk3327 vijayk3327 self-assigned this Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation question Further information is requested
Projects
Status: No status
Development

No branches or pull requests

1 participant