Ask Search:
Gordon InglisGordon Inglis 

Dynamic filters for reports?

Hi,

I would like to run an Events report which produces data based on a particular Company record.  Is there any way this can be done based on the company record you are in?

Ideally would go like this:-
Open up company record A, click a link to the events reports, dynamically pass in Company A and the report shows the data.

Thanks
Best Answer chosen by Moderator (salesforce.com) 
Nebojsa ZgonjaninNebojsa Zgonjanin
Hello,

To reference Account name in Custom buton/link use: {!Account.Name}

You need to associate it to appropriate report filter parameter pv0; pv1;...

If you have just one parameter in report filter it would be something like:

/00O2000000155hj?pv0={!Account.Name}

Regards,
Nash

All Answers

Nebojsa ZgonjaninNebojsa Zgonjanin
Hello,
Yes this is possible.

First create report with filter parameter that has company name or Id as value. Save it.
Use it to custom create button or link that will run report.

In code for run button pass parameter value for filter like:

/00O2000000155hj?pv0={!AccountId}

where 00O2000000155hj is report id

pv0 is value of parameter 1

You can see more here:
http://boards.developerforce.com/t5/Best-Practices-Discussion/Creating-custom-report-links-to-change-filter-critera/m-p/58957?view=by_date_ascending

Regards,
Nash

Gordon InglisGordon Inglis
Thanks - the bit I am unsure of from the link you sent is step 2:-

2. Add advanced filters that you want to populate with the merge fields. 

How do I reference the Account name field in the paramter?  I have tried various ways none work.

Thanks

Nebojsa ZgonjaninNebojsa Zgonjanin
Hello,

To reference Account name in Custom buton/link use: {!Account.Name}

You need to associate it to appropriate report filter parameter pv0; pv1;...

If you have just one parameter in report filter it would be something like:

/00O2000000155hj?pv0={!Account.Name}

Regards,
Nash

This was selected as the best answer