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
rob3000rob3000 

Two Problems with Event printouts

Hi,

 

I'm just recently started Visualforce page development and so I apologize for asking real noob questions here. I could not  find a solution elsewehre though.:

 

Our Sales Reps wish to be able to print out event results. They write those results in the "description" field of events.

 

My first attempt was to simply create a custom button that triggers a standard jjavascript function: window.print(). But that does not work since it causes IE to crash and it also prints all the headers, sidebar etc.and thus looks really bad.

So my second attempt was to create a Visualforce page that grabs all relevant Event details and renders them as PDF. So they can go ahead and print or save that PDF.

 

That 2nd attempt seems more promising but I currently can not get over two problems:

1) Event.What and Event.Who deliver the Account and Contact associated with the Event - But how can I get to further details like email or address? E.G. Event.Who.Email seems not to work.

2) When I save my page wiht <apex:page standardController="Event" renderAs="PDF"> the resulting PDF looks wild, no formats etc. How can I get this pdf to look like the Salesforce Page?

 

Any help is much appreciated!

 

 



Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

Who and What are polymorphic, so you won't just be able to follow the relationship.  You'll need to determine the underlying sobject type of the who/what and execute a SOQL query to bring back the details.

 

Are you using css or <style> tags for your styling?  I've found that doesn't work too well with VF/PDF - inline styles tend to do the trick.