Adding a Button to Run a Report
To add a button to the detail page of the tab associated with the object on which the report is to run:
- From Setup, click Create | Objects |
YourObject
. - Scroll to the Buttons, Links and Actions.
- Click New Button or Link.
- Complete the Label and Name fields.
- Click Detail Page Button.
- Select Display in new window from the Behavior drop-down list.
- Depending on what your users will do with the report, do one or both of the following:
-
If your users will save the report and send it by email, paste the following code into the text box under the Select Field Type drop-down list:
/apex/ob1__OutputManager?id={! YourObjectAPI.Id}&class=YourTemplateClass
-
If your users will only view the report in a pop-up window, paste the following code into the text box (under the Select Field Type drop-down list) to create a "View Only" button:
/apex/ob1__OutputViewer?id={! YourObjectAPI.Id}&class=YourTemplateClass
- Key:
YourObjectAPI
= the API name of the object on which you are creating the report.YourTemplateClass
= the name of the template class to which the report belongs. - Click Save.
- Add the Detail Page Button you created to the page layout of the object.
- If you haven't already done so, add the Output Histories related list to the page layout of the object.
To add a button to the list view of the tab associated with the object on which the report is to run:
- From Setup, click Create | Objects |
YourObject
. - Scroll to the Buttons, Links, and Actions section.
- Click New Button or Link.
- Complete the Label and Name fields.
- Click List Button.
- Ensure that the Display Checkboxes (for Multi-Record Selection) checkbox is selected.
-
Paste the following in the large box beneath the Select Field Type drop-down list:
var tmp='';
var arr = {!GETRECORDIDS($ObjectType.YourObjectAPI
)};
for(var i=0;i<arr.length;i++)
{
tmp+=arr[i]+',';
}
var url = '/apex/ob1__OutputListViewManager?&class=NameofTemplateClass
&idset=' + tmp;
window.open(url, '_blank', 'height=600,location=no,resizable=yes,toolbar=no,status=no,menubar=no,scrollbars=1');
Where:var arr = {!GETRECORDIDS($ObjectType.
YourObjectAPI
)};
for(var i=0;i<arr.length;i++)
{
tmp+=arr[i]+',';
}
var url = '/apex/ob1__OutputListViewManager?class=NameofTemplateClass
&idset=' + tmp;
self.location=url;YourObjectAPI
is the API name of the object on which you are creating the report.NameofTemplateClass
is the is the name of the template class to which the report relates.
- Add the List Button you created to the List View in the Search Layouts section of the object.
- If you have not already done so, add the Output Histories related list to the page layout on the object on which the report is to run.