13

Is it possible to pass variables to Joined Reports (as in pv0=) and/or is it possible to set the Time Frame selector for each report in a Joined Report?

The problem I am trying to solve is having one Joined Report (with 4 blocks) serve to provide multiple time ranges (last qtd, last year, current ytd, etc.) I want to avoid creating 4 copies of the same joined report with only the time range differing.

1
  • i deleted the answer as you are right .tried with joint and no luck Commented Feb 20, 2013 at 18:24

1 Answer 1

10

With the introduction of Joined Reports, Salesforce appears to have begun a fundamental shift in their Reports Runtime. Two of the major components of this shift, for Joined Reports, are:

  1. Report Metadata is passed around / defined as a JSON string called "runReportJson", "editReportJson", depending on whether you are Running a Report or Editing a Report, respectively.
  2. This metadata is expected to be sent through POST - passing in this value through GET / query string parameters does not affect a Joined Report's runtime.

So, in order to do what you're looking for, I believe you'll have to several things:

  1. Instead of sending users to a Report using a simple GET, you'll have to make a POST.
  2. You'll have to include the following POST variables / form data:
    • op: run
    • repId: <id of the report>
    • runReportJson: <a very complex, report-specific JSON string>

To modify parameters such as Dates, you'll have to change either the filters or reportParams attribute(s) of the runReportJson object. You can figure out what your Joined Report's runReportJson looks like by doing the following:

  1. Navigate to your Report in Salesforce.
  2. Open your browser's Developer Tools.
  3. Click "Run Report".
  4. From the Developer Tools, go to the 'Network' section, and click on the first entry in the left sidebar (called "Name" or "Path"). This entry should be the POST request to the Report servlet page, so it should be called /<id of your report>.
  5. Click on "Headers", then scroll down to "Form Data". You should see the above mentioned 3 POST Variables, looking something like this:

enter image description here

  1. Notice the area I have highlighted in a red box --- this "filters" attribute of the runReportJson object is what you'll need to modify to pass parameters into your report. Notice that this attribute is an Array of filter objects. Each filter object looks something like this:

    { "pc" : "<Filtered Field's Id, e.g. ACCOUNT_NAME>", "pn" : "<filter operator, e.g. eq >", "pv" : "<Filter Value you want to insert>" }

There may be multiple of these "filters" attributes for each Block in your Joined Report, so you may need to pass values in to all of them through POST.

The "reportParams" attribute can also be modified to pass-in the higher-up Report parameters such as Date ranges. This usually comes right after the "filters" attribute in the JSON object.

5
  • I got this working using Onclick Javascript from a detail button, and using XmlHttpRequest() object. The filtering is as @zachelrath suggests - it's a bit of a pain to get working but can be done. Used this site to URL encode the JSON, since this has to be done to pass as POST params. Also ensure the request header is in place: request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    – Stephen B
    Commented Nov 13, 2013 at 4:12
  • I have similar problem in my project now, If you dont mind can you please share me the script so that i can use it as a reference. Thank you in advance!
    – user4473
    Commented Nov 14, 2013 at 16:03
  • @Santhosh gist.github.com/stephenbrown1/7443749
    – Stephen B
    Commented Nov 15, 2013 at 4:07
  • @StephenB - just going through your code now. I'm trying to amend it to pass a bunch of parameters from Contracts and Accounts to a joined report. I note at the top you are populating an array with a bunch of ID's, which I assume is tailored to your specific solution. What should I be doing in this instance for myself? Should I simply replace your custom object field reference with "Contracts" as I am working from a straight up Standard Object? Apologies if this sounds garbled!
    – 44f
    Commented Oct 9, 2014 at 10:00
  • Don't worry. Figured it out in the end.
    – 44f
    Commented Oct 10, 2014 at 10:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .