VF "Printable View" that prints the current page layout of Object A along with report data,





<apex:page standardController="Object_A__c" extensions="PrintableViewController">
    <apex:form>
        <apex:outputPanel id="printPanel">
            <h1>Printable View - {!Object_A__c.Name}</h1>

            <!-- Display the current record's page layout data -->
            <apex:detail subject="{!Object_A__c}" relatedList="false"/>

            <hr/>

           <h2>Report Data</h2>
<apex:pageBlockTable value="{!reportData}" var="report">
    <apex:column headerValue="Field 1">
        <apex:outputText value="{!report.Field_1__c}" />
    </apex:column>
    <apex:column headerValue="Field 2">
        <apex:outputText value="{!report.Field_2__c}" />
    </apex:column>
    <!-- Add more columns as necessary -->
</apex:pageBlockTable>
        </apex:outputPanel>
        <apex:commandButton value="Print" onclick="window.print();" />
    </apex:form>
</apex:page>

public with sharing class PrintableViewController {
    public List reportData { get; set; }
    public Object_A__c record { get; set; }

    public PrintableViewController(ApexPages.StandardController controller) {
        this.record = (Object_A__c)controller.getRecord();
        // SOQL query to fetch report data related to this record
        reportData = [SELECT Field_1__c, Field_2__c FROM ReportObject__c WHERE Object_A__c = :record.Id];
    }
}


VF "Printable View" that prints the current page layout of Object A along with report data, VF "Printable View" that prints the current page layout of Object A along with report data, Reviewed by dasfrogpractice on 09:54 Rating: 5

No comments:

Theme images by mariusFM77. Powered by Blogger.
Youtube Channel Image
Dasfrog Subscribe To watch more Salesforce Training
Subscribe