Question about Custom Buttons that link to Reports that take URL parameter for filtering:
We have several Custom Buttons (type=List Button) on various objects that link to Reports that take URL parameters pv0 to filter the results based on the object record ID that they were clicked from
Here's a sample: https://www.screencast.com/t/CMXS5bxHu
In LEx, the pv0 parameter is now fv0 and the URL to the Report needs to use the LEx hash fragment as described here:
https://releasenotes.docs.salesforce.com/en-us/spring17/release-notes/rn_rd_reports_filter_url.htm
The problem is -- I need the button to work the "Classic" way for users of my app that are still in Classic .. and work the LEx way when a user has enabled LEx.
I tried getting crafty like so:
{!URLFOR($Action.Report.ReportRunAction, "00O800000031PZf",[pv0=Account.Id,fv0=Account.Id])}
That URL formula works for Classic, but the fv0 parameter is stripped off when in LEx
So then I tried a more explicit formula:
{!IF(($User.UIThemeDisplayed == "Theme4d" || $User.UIThemeDisplayed == "Theme4t"), "#/sObject/00Oi0000000fAYm/view?fv0=" + URLENCODE(Account.Id), URLFOR($Action.Report.ReportRunAction, "00Oi0000000fAYm",[pv0=Account.Id]))}
No luck there; the hash fragment is URLEncoded and you end up at a 'not found' page.
I am at a dead end here .. where the only option is to create two buttons, one for LEx and the other for Classic, place them both on the page layout and tell the user that if they're in LEx, they have to click on one, and if not, click on the other. That is suboptimal.
Has anyone found a workaround here? I found these two articles that both suggest that I am indeed at a dead end
http://www.sfdccloudninja.com/lightning/url-hacks-as-buttons-in-lightning-experience/
https://biggerboatconsulting.com/supporting-report-filter-url-hacks-in-lightning-and-classic/
I haven't found an answer. I'm resorting to a LEX-specific button. I did post an idea on this though, if you'd like to upvote and share it:
https://success.salesforce.com/ideaView?id=0873A000000TulfQAC