+ Start a Discussion
Sorcerer7Sorcerer7 

Output format for a custom button

On our Opportunity page layout, there is a custom button called "Quote". The code behind this button exports the data into an Excel spreadsheet.
I need to find a way to export it into a different format, preferrably either a Word doc or a PDF.
Here is the code for the button now...

/00OF0000003vtec?export=1&enc=UTF-8&xf=csv&pv0={!Opportunity.Id}

I am hoping it's as easy and just changing the "csv" in the formula to "doc": or "pdf".

Thanks
Best Answer chosen by Sorcerer7
JustAGirlyGeekJustAGirlyGeek
That link appears to be allowing you to quickly export a Salesforce report:

http://salesforce.stackexchange.com/questions/13602/custom-link-to-download-export-report-in-single-click

In order to be able to export to pdf, you can use a Visualforce page with the 'RenderAs="pdf"' tag:

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_quick_start_renderas_pdf.htm
 

All Answers

JustAGirlyGeekJustAGirlyGeek
That link appears to be allowing you to quickly export a Salesforce report:

http://salesforce.stackexchange.com/questions/13602/custom-link-to-download-export-report-in-single-click

In order to be able to export to pdf, you can use a Visualforce page with the 'RenderAs="pdf"' tag:

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_quick_start_renderas_pdf.htm
 
This was selected as the best answer
Shashi PatowaryShashi Patowary
Hi,

The code behind the button is redirecting to a SFDC report which is then converted to an excel (as instructed in the query parameter).Currently there is no way to view SFDC report in PDF.So to achieve your requirement, you need to implement a custom VF page that can be rendered as PDF.

Please let me know if this helps.

Regards,
Shashi
 
Sorcerer7Sorcerer7
Since by default, it exports to Excel, is it possible to have it export to Word as that is also a MS product?
JustAGirlyGeekJustAGirlyGeek
Unfortunately, the only options for the current url are xls or csv. PDF or Word would require a custom button referencing a custom Visualforce page.
Sorcerer7Sorcerer7
But I could create a VF page and then have the button point to that page.
Within the code on the page I just need to add the ...renderAs "doc". Is that correct?
JustAGirlyGeekJustAGirlyGeek
Yes, it can be done but the tag is slightly different. You will use the following instead:

<apex: page contentType="application/msWord">

Here is an example:
https://success.salesforce.com/answers?id=90630000000gqOiAAI
Sorcerer7Sorcerer7
Thank you. I'll see what they want to do.
JustAGirlyGeekJustAGirlyGeek
Happy to help!