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
Dan FenlonDan Fenlon 

how to add a custom export button in Cases

can someone share with me step by step as to how i would add a custome button to be able to export a single case. my customers want copies and wanted to be able to export them to word or pdf so i can email them to them
Saurabh BSaurabh B
Hi Dan,
Below are few options,
  1. You can use Free tool available on Appexchange which allows to convert records in PDF - https://appexchange.salesforce.com/listingDetail?listingId=a0N3000000B3CsNEAV
  2. Other option is to create Visualforce page using renderAs="pdf" attribute in <Apex:page>

Please mark this as Best Answer if it helps you!
 
Dan FenlonDan Fenlon
thanks for the reply. unfortuntaly like the review say for option 1 their is no custimzation making this not an option
2. can you include a walkthrough of the stpes to do this. im not familir wiith this. a screen shot. whatever you can include would be helpful
Saurabh BSaurabh B
Dan, here is the VF page i created in my Dev Org. Follow below steps,

1) Create this Visualforce page in your org
 
<apex:page standardController="Case"  renderAs="pdf">

    <table width="100%" style="font-family: Arial, Helvetica, sans-serif; border-collapse: collapse;"
        cellpadding="5">
        <tr>
            <td colspan="4">
                Case
            </td>
        </tr>
        <tr>
            <td colspan="4" style="font-size: x-large; font-weight: bold">
                {!Case.Subject}
            </td>
        </tr>
        <tr>
            <td colspan="4">
            </td>
        </tr>
        <tr>
            <td colspan="4" style="font-weight: bold; border-bottom-style: solid; border-bottom-width: thick;
                border-bottom-color: #b7a752;">
                Case Information
            </td>
        </tr>
        <tr>
            <td align="right" style="color: #808080; border-right-style: solid; border-right-width: thin;
                border-right-color: #b7a752;">
                Priority
            </td>
            <td style="font-weight: bold">
                {!case.Priority}
            </td>
            <td align="right" style="color: #808080; border-right-style: solid; border-right-width: thin;
                border-right-color: #b7a752;">
                Status
            </td>
            <td style="font-weight: bold">
                {!case.Status}
            </td>
        </tr>
        <tr>
            <td align="right" style="color: #808080; border-right-style: solid; border-right-width: thin;
                border-right-color: #b7a752;">
                Subject
            </td>
            <td style="font-weight: bold">
                {!case.Subject}
            </td>
        </tr>
        <tr>
            <td align="right" style="color: #808080; border-right-style: solid; border-right-width: thin;
                border-right-color: #b7a752;">
                Type
            </td>
            <td style="font-weight: bold">
                {!case.Type}
            </td>
            <td align="right" style="color: #808080; border-right-style: solid; border-right-width: thin;
                border-right-color: #b7a752;">
                Account
            </td>
           
            <td style="font-weight: bold">
                {!Case.Account.Name}
            </td>
        </tr>
        <tr>
            <td align="right" style="color: #808080; border-right-style: solid; border-right-width: thin;
                border-right-color: #b7a752;">
                Origin
            </td>
            <td style="font-weight: bold">
                {!case.Origin}
            </td>
           
          
        </tr>
        
    </table>

    </apex:page>

2) After above Visualforce page is created, create a Visualforce button on case object (see screenshot below)

User-added image

3) Now add that button on Case page layout. Thats it. This will allow you to download case in PDF and will maintain look and feel of Salesforce. Modify the code as per your need.

Hope this helps!

-Saurabh

Please mark this as Best Answer if it helped you!
Dan FenlonDan Fenlon
thansk again for taking the time to put this together. a couple things
1. i renemaed cases to work orders. do i need to substtitue in "Work_Orders" for case in the script above
2. in your Screenshot under content the only thing i have in the drop down is "export button" which i named the button. i dont see the text u have above in there
Saurabh BSaurabh B
Hi Dan,
1) if you have just renamed Cases to 'Work Orders' then no need to change. But if you have created a new object in Salesforce, then you may have to change it.
2)  you will have to create a new button and then add it to the layout.
Go to Setup> Case > button and links and create a new button. You should see a visual force page that you have created in the drop down. Select the page that you created in step 1 and save the button. That's it.

Please mark this as Best Answer if it helps you.
Dan FenlonDan Fenlon
thanks. must be the case. it downloads it and then i go to open it and and i get an error. i changed it work order before i entered the script.
so should i go through and replace everything that says case in the script to "Work_Orders" just as i wrote it. assuming i need the underscore maybe not, noticed in most code you need an underscore when their is 2 words in the heading?