Salesforce Reports URL Hack

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.

Screen Shot 2015-02-09 at 13.05.37Even 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.

Screen Shot 2015-02-09 at 13.52.04

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?

Screen Shot 2015-02-09 at 13.54.23

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.

Screen Shot 2015-02-09 at 13.57.38

 

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.

 

Screen Shot 2015-02-09 at 13.05.37

 

So in the above example if we wanted to populate each field in the filters our URL would look something like this.

/00Oi0000005wvrc?pv0={!Account.Id}&pv1={!Account.Type}&pv2={!Account.Key_Account__c}

But seeing as we don’t have these fields in our example we just need the first bit.

/00Oi0000005wvrc?pv0={!Account.Id}

That’s done! Report URL Hacking Complete!

SalesforceBenHeader

Subscribe To The Monthly Newsletter

No Spam. No Rubbish. Just great content from the Salesforce Industry.

You have Successfully Subscribed!

4 thoughts on “Salesforce Reports URL Hack

  1. Hi,

    Any suggestions for creating links to reports where the filters relate to the user clicking the link?

    Scenario: My users need to see where their name is listed in a lookup field to the user ID. I created a report and followed your instructions.

    Report Filter: Lead Broker: User ID equals “”

    Custom Link: /00Oo0000004WlM9?pv0={!User.Id}

    It inserts the text – {!User.Id} which of course returns no results.

    I’m at a loss, any help would be appreciated. Not sure if it matters, but the report is related to a custom object.

    Thanks!

    1. Hi Christopher, so the only thing which is different here to something normal is that user is a global variable. However I tried this out myself and it works fine. This is my exact link URL – /00Oi0000005xrvZ?pv0={!$User.FirstName}+{!$User.LastName}

      It works fine, are you launching thing off a link then?

  2. I’m looking to push the limits. I know we can dynically pass field values, filter logic, and I believe operators, but is it possible to dynamically pass fields?

    Ex. From oppty record type “A” we want to see pv0 as acct = (dynamic value) and for oppty record type “B” we see pv0 as owner = (dynamic value).

    Envision a report with 15 filters that say ID null and we pass the field, operator, value, and filter logic dynamically and use 1 report per CRT to rule them all. What can and can’t we do?

Add Comment