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
MarniMarni 

Custom 'Printable View' using Visualforce page

I am very new to Visualforce Pages so I apologize in advance for such a broad question.  .  I am looking to create a new Button/Link that will open a Visualforce page that simply displays the fields and responses on a simply layout for a user to print (basically the 'Printable View' but with no logos or references to SalesForce.  I also don't want it to show any of the headers, sidebars, etc. of SalesForce.  I just want it to show the fields and responses as they appear on screen.  Very simple, very plain.   I tried copying the Source Code of the Printable View link to get me started but I had two issues:

 

1. Once I added the standardcontroller of my Custom Object in order to get the page to appear as an available option for a custom button, it added in all of the header, side bars, etc.of SalesForce. 

2.  I also realized that it was simply showing the text of the responses rather than directing the page to pull that records responses.  I tried replacing the text that appears in the code with references to the object field but I keep getting errors.

 

Any advice or an example of how I can accomplish this would be greatly appreciated!  Thank you!

Best Answer chosen by Admin (Salesforce Developers) 
MarniMarni

I was able to find my own solution.

All Answers

MarniMarni

I was able to make a lot of progress on this and my only remaining issue is how to reference fields on the object.  I have tried {field name} but that just appears as text on the page.  I have tried {!object.field_name__C} and that returns errors.  How do I do this? 

 

Below is a small part of the code that is currently working (but I need to replace a lot of the text with a field reference).

 

<apex:page standardController="Audit_Claim__c" showHeader="false" sidebar="false" >
<!-- Main Body Starts Here -->
<a href="#skiplink" class="navSkipLink assistiveText">Skip to main content</a><div class="print"><div class="printHeader"><div class="printControls"><ul><li><a href="javascript&colon;window.close%28%29%3B">Close Window</a></li><li><a href="javascript&colon;window.print%28%29%3B">Print This Page</a></li>

<div class="bPageBlock secondaryPalette" id="mainTable"><div class="pbHeader pbHeaderEmpty"><table  border="0" cellpadding="0" cellspacing="0"><tr><td class="pbTitle"><h2 class="mainTitle"></h2></td><td class="pbButton" id="topButtonRow">&nbsp;</td></tr>
</table></div><div class="pbSubsection"><table  class="detailList" border="0" cellpadding="0" cellspacing="0"><tr><td class="labelCol">Audit Profile</td><td class="dataCol col02">{Audit_Profile_Name__C}</td><td class="labelCol">Owner</td><td class="dataCol">{Owner}</td></tr>



Where you see {Audit_Profile_Name__c} and {Owner} is where I want the field reference to be.

 

Also, the Close Window link in this part of the code appears to have stopped working.  Is that an easy fix?

 

Any help is greatful!  Thanks!



MarniMarni

I was able to find my own solution.

This was selected as the best answer
crmdeepscrmdeeps

Can u please share the solution that you found yourself? i am struggling with the print preview option for a visual force page. Thanks in Advance!

MarniMarni

This code is unique to our fields but hopefully it will help in what you are looking to do.....

 

<apex:page standardController="Audit_Claim__c" showHeader="false" sidebar="false" >
<!-- Main Body Starts Here -->
<div class="print"><div class="printHeader"><div class="printControls"><ul><li><a href="JavaScript&colon;window.close()">Close Window</a></li><li><a href="javascript&colon;window.print%28%29%3B">Print This Page</a></li>
<p><b><font size="4">{!Audit_Claim__c.Audit_Profile__r.name}</font></b></p>
<p><b><font size="3">{!Audit_Claim__c.Name}</font></b></p>
<div class="bPageBlock secondaryPalette" id="mainTable"><div class="pbHeader pbHeaderEmpty"><table  border="0" cellpadding="0" cellspacing="0"><tr><td class="pbTitle"><h2 class="mainTitle"></h2></td><td class="pbButton" id="topButtonRow">&nbsp;</td></tr>
</table></div><div class="pbSubsection"><table  class="detailList" border="0" cellpadding="0" cellspacing="0"><tr><td class="labelCol">Audit Profile</td><td class="dataCol col02">{!Audit_Claim__c.Audit_Profile__r.name}</td><td class="labelCol">Owner</td><td class="dataCol">{!Audit_Claim__c.Owner.Name}</td></tr>
<tr><td class="labelCol">Carrier</td><td class="dataCol col02">{!Audit_Claim__c.Carrier__r.Name}</td><td class="labelCol">Claimant Name</td><td class="dataCol">{!Audit_Claim__c.Claimant_Name__c}</td></tr>
<tr><td class="labelCol">Carrier Claim Number</td><td class="dataCol col02">{!Audit_Claim__c.Name}</td><td class="labelCol">Carrier DOL<td class="dataCol"><apex:outputText value="{0,date,MM/dd/yyyy}"><apex:param value="{!Audit_Claim__c.Carrier_DOL__c}"/></apex:outputText></td></td></tr>

<tr><td class="labelCol">Suffix</td><td class="dataCol col02">{!Audit_Claim__c.Suffix__c}</td><td class="labelCol">Date Reported to Carrier<td class="dataCol"><apex:outputText value="{0,date,MM/dd/yyyy}"><apex:param value="{!Audit_Claim__c.Date_Reported_to_Carrier__c}"/></apex:outputText></td></td></tr>
<tr><td class="labelCol">Insured Name</td><td class="dataCol col02">{!Audit_Claim__c.Insured_Name__c}</td><td class="labelCol">CH</td><td class="dataCol">{!Audit_Claim__c.CH__c}</td></tr>
<tr><td class="labelCol last">Program</td><td class="dataCol col02 last">{!Audit_Claim__c.Program__c}</td><td class="labelCol last">Business Type</td><td class="dataCol last">{!Audit_Claim__c.Business_Type__c}</td></tr>
</table></div><div class="pbSubheader tertiaryPalette" id="head_01BA000000c9tJc_mainTable"><img src="/s.gif" alt="Hide Section - Claim Details"  class="hideListButton" id="img_01BA000000c9tJc" name="Claim Details" onclick="twistSection(this);" style="cursor:pointer;" title="Hide Section - Claim Details"/><h3>Claim Details<span  class="titleSeparatingColon">:</span></h3></div><div class="pbSubsection"><table  class="detailList" border="0" cellpadding="0" cellspacing="0"><tr><td class="labelCol">Handler</td><td class="dataCol col02">{!Audit_Claim__c.Handler__c}</td><td class="labelCol">Supervisor</td><td class="dataCol">{!Audit_Claim__c.Supervisor__c}</td></tr>
<tr><td class="labelCol">Claim Status</td><td class="dataCol col02">{!Audit_Claim__c.Claim_Status__c}</td><td class="labelCol">Closed Date</td><td class="dataCol">{!Audit_Claim__c.Closed_Date__c}</td></tr>
<tr><td class="labelCol">Accident Year</td><td class="dataCol col02">{!Audit_Claim__c.Accident_Year__c}</td><td class="labelCol">Office</td><td class="dataCol">{!Audit_Claim__c.Office__c}</td></tr>
<tr><td class="labelCol">General Allegation</td><td class="dataCol col02">{!Audit_Claim__c.General_Allegation__c}</td><td class="labelCol">Primary Allegation</td><td class="dataCol">{!Audit_Claim__c.Primary_Allegation__c}</td></tr>
<tr><td class="labelCol">Coverage</td><td class="dataCol col02">{!Audit_Claim__c.Coverage__c}</td><td class="labelCol">Danger Signal</td><td class="dataCol">{!Audit_Claim__c.Danger_Signal__c}</td></tr>
<tr><td class="labelCol last">Nature of Notice</td><td class="dataCol col02 last">{!Audit_Claim__c.Nature_of_Notice__c}</td><td class="labelCol last">Description of Loss</td><td class="dataCol last">{!Audit_Claim__c.Description_of_Loss__c}</td></tr>
</table></div><div class="pbSubheader tertiaryPalette" id="head_01BA000000c9tJd_mainTable"><img src="/s.gif" alt="Hide Section - Policy Information"  class="hideListButton" id="img_01BA000000c9tJd" name="Policy Information" onclick="twistSection(this);" style="cursor:pointer;" title="Hide Section - Policy Information"/><h3>Policy Information<span  class="titleSeparatingColon">:</span></h3></div><div class="pbSubsection"><table  class="detailList" border="0" cellpadding="0" cellspacing="0"><tr><td class="labelCol">Policy #</td><td class="dataCol col02">{!Audit_Claim__c.Policy_Number__c}</td><td class="labelCol">Policy Type</td><td class="dataCol">{!Audit_Claim__c.Policy_Type__c}</td></tr>
<tr><td class="labelCol">Original Policy Currency</td><td class="dataCol col02">{!Audit_Claim__c.Original_Policy_Currency__c}</td><td class="labelCol">Policy Year</td><td class="dataCol">{!Audit_Claim__c.Policy_Year__c}</td></tr>
<tr><td class="labelCol">Policy Incept</td><td class="dataCol col02"><apex:outputText value="{0,date,MM/dd/yyyy}"><apex:param value="{!Audit_Claim__c.Policy_Incept__c}"/></apex:outputText></td><td class="labelCol">Policy Expiration</td><td class="dataCol"><apex:outputText value="{0,date,MM/dd/yyyy}"><apex:param value="{!Audit_Claim__c.Policy_Expiration__c}"/></apex:outputText></td></tr>
<tr><td class="labelCol">Policy Limit</td><td class="dataCol col02"><apex:outputField id="pl" value="{!Audit_Claim__c.Policy_Limit__c}"/></td><td class="labelCol">Underwriter</td><td class="dataCol">{!Audit_Claim__c.Underwriter__c}</td></tr>
<tr><td class="labelCol">Broker</td><td class="dataCol col02">{!Audit_Claim__c.Broker__c}</td><td class="labelCol">SIR</td><td class="dataCol"><apex:outputField id="sir" value="{!Audit_Claim__c.SIR__c}"/></td></tr>
<tr><td class="labelCol">Line of Business</td><td class="dataCol col02">{!Audit_Claim__c.Line_of_Business__c}</td><td class="labelCol">Primary / Excess</td><td class="dataCol">{!Audit_Claim__c.Primary_Excess__c}</td></tr>
<tr><td class="labelCol last">Reinsurance Report</td><td class="dataCol col02 last">{!Audit_Claim__c.Reinsurance_Report__c}</td><td class="labelCol last">Attachment Point (If Excess)</td><td class="dataCol last"><apex:outputField id="ap" value="{!Audit_Claim__c.Attachment_Point_If_Excess__c}"/></td></tr>

</table></div><div class="pbSubheader tertiaryPalette" id="head_01BA000000c9tJe_mainTable"><img src="/s.gif" alt="Hide Section - Suit Information"  class="hideListButton" id="img_01BA000000c9tJe" name="Suit Information" onclick="twistSection(this);" style="cursor:pointer;" title="Hide Section - Suit Information"/><h3>Suit Information<span  class="titleSeparatingColon">:</span></h3></div><div class="pbSubsection"><table  class="detailList" border="0" cellpadding="0" cellspacing="0"><tr><td class="labelCol">Plaintiff Counsel</td><td class="data2Col" colspan="3">{!Audit_Claim__c.Plaintiff_Counsel__c}</td></tr>
<tr><td class="labelCol">Defense Counsel</td><td class="data2Col" colspan="3">{!Audit_Claim__c.Defense_Counsel__c}</td></tr>
<tr><td class="labelCol last">Coverage Counsel</td><td class="data2Col last" colspan="3">{!Audit_Claim__c.Coverage_Counsel__c}</td></tr>

</table></div><div class="pbSubheader tertiaryPalette" id="head_01BA000000c9tJf_mainTable"><img src="/s.gif" alt="Hide Section - Financials"  class="hideListButton" id="img_01BA000000c9tJf" name="Financials" onclick="twistSection(this);" style="cursor:pointer;" title="Hide Section - Financials"/><h3>Financials<span  class="titleSeparatingColon">:</span></h3></div><div class="pbSubsection"><table  class="detailList" border="0" cellpadding="0" cellspacing="0"><tr><td class="labelCol">Indemnity O/S</td><td class="dataCol col02"><apex:outputField id="ios" value="{!Audit_Claim__c.Indemnity_O_S__c}"/></td><td class="labelCol">Indemnity PD</td><td class="dataCol"><apex:outputField id="ipd" value="{!Audit_Claim__c.Indemnity_PD__c}"/></td></tr>
<tr><td class="labelCol">Claims Expense O/S</td><td class="dataCol col02"><apex:outputField id="cos" value="{!Audit_Claim__c.Claims_Expense_O_S__c}"/></td><td class="labelCol">Claims Expense PD</td><td class="dataCol"><apex:outputField id="cpd" value="{!Audit_Claim__c.Claims_Expense_PD__c}"/></td></tr>

<tr><td class="labelCol">Expense Within Res</td><td class="dataCol col02"><apex:outputField id="ewr" value="{!Audit_Claim__c.Expense_Within_O_S__c}"/></td><td class="labelCol">Expense Within PD</td><td class="dataCol"><apex:outputField id="ewp" value="{!Audit_Claim__c.Expense_Within_PD__c}"/></td></tr>
<tr><td class="labelCol">Total Reserves</td><td class="dataCol col02"><apex:outputField id="tr" value="{!Audit_Claim__c.Total_Reserves__c}"/></td><td class="labelCol">Paid to Date</td><td class="dataCol"><apex:outputField id="tp" value="{!Audit_Claim__c.Paid_to_Date__c}"/></td></tr>
<tr><td class="labelCol last">Total Incurred</td><td class="dataCol col02 last"><apex:outputField id="ti" value="{!Audit_Claim__c.Total_Incurred__c}"/></td><td class="labelCol last">IBNR</td><td class="dataCol last"><apex:outputField id="ib" value="{!Audit_Claim__c.IBNR__c}"/></td></tr>
</table></div><div class="pbSubheader tertiaryPalette" id="head_01BA000000c9tJi_mainTable"><img src="/s.gif" alt="Hide Section - Evaluation"  class="hideListButton" id="img_01BA000000c9tJi" name="Evaluation" onclick="twistSection(this);" style="cursor:pointer;" title="Hide Section - Evaluation"/><h3>Evaluation<span  class="titleSeparatingColon">:</span></h3></div><div class="pbSubsection"><table  class="detailList" border="0" cellpadding="0" cellspacing="0"><tr><td class="labelCol">Coverage Evaluation</td><td class="data2Col" colspan="3">{!Audit_Claim__c.Coverage_Evaluation__c}</td></tr>

<tr><td class="labelCol">LVL Evaluation</td><td class="data2Col" colspan="3">{!Audit_Claim__c.LVL_Evaluation__c}</td></tr>
<tr><td class="labelCol last">Additional Recommendations/Comments</td><td class="data2Col last" colspan="3">{!Audit_Claim__c.Additional_Recommendations__c}</td></tr>
</table></div></div><div class="pbFooter secondaryPalette"><div class="bg"></div></div></ul></div><div class="bPageFooter" id="bodyFooter"><div class="footer">Privileged and Confidential - LVL Claims Services, LLC</div></div></div></div>

</apex:page>