URL Hacking Cross Filter Reports

Warning: The Following Post is a Completely Unsupported Hack. Salesforce may make changes at any time that makes this not work.

You probably know how to pass report parameters using the url. This is helpful when you want to create links from a record in Salesforce to a related report. Cross filter reports can also be passed parameters, but it is a little more difficult to do than with a standard filter.

The first thing I did is create a report that uses a cross filter. In this example, we’ll look for accounts that have an opportunity with a close date after a certain date.

cross filter report

I then looked at the page source and found the relevant hidden fields we need to work with.

cross filter source

As you can see there are a lot of fields that need to be provided. Unfortunately you can’t set up the cross filter and just pass in the values like you can with standard filters. You need to pass in all filters and save the report without a cross filter.

Let’s examine each one to try and figure out what they mean.

ptable0 – This parameter corresponds to the main object in your report. I haven’t quite figured out what goes here, but it seems to be CUST_ID for custom objects and [OBJECT NAME]_ID for standard objects.

ocond0 – Use w for with and wo for without

rtable0 – This is the cross filtered object. It should be the object name for standard objects and the object ID for custom ones.

rtablecol0 – This is the column on the cross filtered object that corresponds to the parent object.  For standard objects, use the field name and and for custom objects, use the field ID.

sfpc0_0 – This is the field to filter on. For standard objects, use the field name and and for custom objects, use the field ID.

sfpn0_0 – This is the filter operator. It can be values such as eq, ne, gt, lt, ge, le.

sfpv0_0 – This is the value you want to filter on.

cross filter report and fields

 

Now that we have a better idea of what each one does, we can use them in a URL. So in this example, our URL will look like this

/[ReportID]?ptable0=ACCOUNT_ID&ocond0=w&rtable0=Opportunity&rtablecol0=Account&sfpc0_0=CloseDate&sfpn0_0=ge&sfpv0_0=1/1/2014

We can just change the date at the end to get it to populate a different date. Just save your report without any cross filters and then use the URL parameters to filter accordingly.

I’ve found that the best way to figure out all the parameters is to first create a report with the filter, run it and then view the page source. Just search for the list of hidden fields and look for the values that you should pass.

Good luck with your URL hacking!

13 thoughts on “URL Hacking Cross Filter Reports”

  1. This looks great, but doesn’t seem to work for me. it just brings up a version of ‘Accounts with Opportunities’ but no filter conditions or whichever object I try to use.
    If for testing I try to duplicate your exact URL just changing report ID it shows no filters.

    1. Check the report type your report is using. I just tested in another org and if I use an Accounts report type, save the report and then paste in the URL, it worked for me.

  2. Thanks for the reply. Ah – so when I tried on a report with a Cross filter, it doesn’t work, but if I use a plain Accounts report then paste the URL suffix it works.
    Wasn’t clear to me I need to remove the cross filter. Great stuff!

  3. Any luck using something like sfpv0_0={!User.Name} to have a filter condition reflect running user? Would be the next level of usefulness…

    1. Yes, that should work. Here’s an example parameters showing Accounts with Opportunities created by me:

      ?ptable0=ACCOUNT_ID&ocond0=w&rtable0=Opportunity&rtablecol0=Account&sfpc0_0=CreatedBy&sfpn0_0=eq&sfpv0_0=Daniel+Hoechst

  4. Yes, awesome. If only we could run a report on Contacts at Accounts – with another object that relates to Accounts as the cross filter.
    thanks!

  5. I am trying to get multiple field filters on the cross object but it’s not taking the second condition.
    can i just add say from : &sfpc0_0=00NU00000037FVp&sfpn0_0=ne&sfpv0_0=’Value’ onto the end if the object is the same?

    thanks!

  6. Just tried this and it worked like a charm. Very cool! Though wish it didn’t need a hack to make it work. I added the code for a custom object.

  7. hey i’m having a problem with this on a custom object and i followed your instructions to the T

    bascially I can get the URL to recognise that it’s a cross filter I’m applying but the &sfpc0_0=00NU00000037FVp&sfpn0_0=ne&sfpv0_0=

    doesn’t get applied at all?

    any tips or ideas on why or what is there something in the report type I need to update?

Leave a Reply