Following on from my 4 Clever Hacks with Custom Buttons post, I’m going to be discussing hacking Salesforce Reports URL to insert custom information from merge fields. As a prerequisite it may be helpful to skim my URL Hacking guide. Before we get started i’d just like you to look at the image below.
Even though its not obvious. These three filters, Account ID, Stage and Key Account are just fields on this page. This means just like my email hack tutorial we can insert information here via the URL.
For this example I’m going to be creating a report that grabs all of the open opportunities for a specified account.
Step 1 – Creating the Template Report
The first step of this URL hack is to actually create the report we want to use in this solution. The key to this part is to create a report like you normally would but leaving the filters that you wish to populate via the URL, Blank.
As you can see from the above its a pretty simple report. I’ve left the Account ID blank as we want to populate this to only get the Opps related to the account were working off. I’ve made the Stage filter static as this is going to be the same every time.
Next we need to save this report and grab the ID which you can find in the URL bar after you save. After the .com/ and before the /e?
Step 3 – Creating the Button/Link
After we’ve got our Report ID for our template Report we are ready to create our Button or Link, for this example I’m going to be creating a link. You want to make sure you have your Report ID handy for this step.
Go to your relevant object and create a new link. It should look similar to mine below. After you have entered the Display Type, Behavior and Content Source, you can copy you report URL with a forward slash into the text area.
This button so far will launch your blank template report, so lets add this to your page layout and then add some parameters!
Step 3 – Adding Report Parameters
I mentioned earlier that the filters on a report are just fields that can be manipulated and populated. These fields always have the same parameter values no matter what they are. Pv stands for parameter value and the code we need look like this pv0= for the first filter, pv1= for the second and pv2= for the third.
So in the above example if we wanted to populate each field in the filters our URL would look something like this.
But seeing as we don’t have these fields in our example we just need the first bit.
That’s done! Report URL Hacking Complete!