I have a Visualforce page that contains a link to a custom report. I'm generating that link in an apex class like this:

reportUrl = '/'  + reportId

Then in the VF page I create the link and add the filter:

<apex:outputLink value="{!reportURL}" target="_blank">
    Open Report
    <apex:param name="fv1" value="{!URLENCODE(userName)}"/>

This worked well SF Classic where the parameter name in the VF code had to be "pv1". In Lightning that has changed to "fv1". Now when I generate the URL it looks just like the classic version but with the "fv1" as expected. However, when I click on the URL in Lightning it redirects and I end up with a different URL that takes me to the report but doesn't include the filter parameter.

Generated URL: https://my_domain.my.salesforce.com/00O40000003SdKeEAK?fv1=Bob%20Smith

Redirected URL: https://my_domain.lightning.force.com/lightning/r/Report/00O40000003SdKeEAK/view

If I take the redirected URL and manually add the "?fv1=Bob%20Smith" then the filter shows up so I know the Lightning report works with the filter parameter.

Is there a way to get the Lightning version of the URL from the Apex class so I can append the filter parameters to that?

2 Answers 2


You can handle the report link with filter parameter by detecting the user theme i.e. classic or lightning in your apex class and then generate the URL according to the theme as follow:-

String theme = UserInfo.getUiThemeDisplayed();
reportUrl = '/'  + reportId + 'pv1='+username;
}else if(theme=='Theme4d' || theme =='Theme4t'){
reportUrl = '/lightning/r/Report/' + reportId + '/view?fv1='+username;

Note:- pv0 will work in Classic only and fv0 will work in Lightning only. Also, When the user right-clicks and opens the URL in a new tab, the filter will not be applied in lightning because theme detection will result in the classic theme value.

Read more here about theme detection:- Introducing UI Theme Detection for Lightning Experience



The document goes through the format and filter format for URLs in Lightning.

In your apex, append the needed parts.

reporturl = '/lightning/r/Report/ + reportId + '/view?fv0' + ' whatever + '&fv1=' + ....
  • Thanks for your suggestion. That link is where I figured out that the parameter name changed in Lightning. It doesn't tell you how to the the URL though. I can do as you suggested. It just seems like, if they have a mechanism to get the URL, it should provide the correct one based on the version of SF you're currently in. I don't see the need for the redirect.
    – JeffMc
    Commented Oct 4, 2019 at 19:20

You must log in to answer this question.

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