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
laytro1978laytro1978 

One button to select different Visualforce PDFs based on criteria

Hi,

 

I have a quick question.  I have two visualforce pages which effectivley PDF the same record in two different formats.  They are activated by two buttons on the object.  The format used is based on a field.  Instead of having two buttons I just want one, which would force some logic (guessing APEX controller) to first look at the field and if it was a certain value it would choose format 1, if it was another value it would choose format 2.  Can anyone point me in the right direction.  Any code snippets or examples would be great.

Shashikant SharmaShashikant Sharma

Just Use two different page block and use rendered attribute, use a controller property

 

public property showFormat1{get;set;}

 

<apex:page                          >
<form>
		<apex:pageblock   rendered='{!showFormat1}"/>
               <!-- All content  format 1-->
               </apex:pageblock>
                                 

<apex:pageblock   rendered='{!NOT(showFormat1)}"/>
               <!-- All content format 2-->
</apex:pageblock> 
</form>
</apex:page>

 let me know if any issue in it.

Laytro80Laytro80

Thanks for this.  I understand (I think) how to do this in visualforce not sure on the APEX code logic.

 

The object is called link (link__c).   It has a field (related lookup) called fund (fund__c).  On the fund object there is a check box called Format 1 (format_one__c). 

 

I need the APEX code to say on the link object:

 

If fund__r.format_one__c equal to true use format 1 if not use format 2

 

Not sure if you have time to help with the Apex controller, any guidance would be appreciated.  

 

Also I know I need to build a test script again very new to me but I can have go might need a few pointers.

 

Thanks again