1

The use of custom links to generate reports in classic Salesforce was possible using the url hacks and it was easy to append the report id at the end of the url and add the dynamic parameters as pv0, pv1 and so on..

But, with the introduction of lightning the url hack is not easy, rather it's very difficult to predict the url within lightning. With Spring'17 release, they have introduced dynamic custom reports

https://releasenotes.docs.salesforce.com/en-us/spring17/release-notes/rn_rd_reports_filter_url.htm

I am looking for ways to use the same custom link to redirect to classic reports as well as lightning reports. Here are the options I tried,

  1. IF with the CONTAINS method to see if the API base url contains "lightning.salesforce.com" (which may not be always true, looking at the release notes example) and then construct a hyperlink based off the IF result. Since the lightning url has multiple parameters, its difficult to hack the url.
  2. I read about Global actions, which would be the the perfect way to overcome the url hacks, but looks like that's more useful when we are trying to create/update records. It doesn't seem to fit my requirements.
3

Not ideal but I ended up creating two custom links - one for Classic and one for Lightning - and adding them to the page layout. I couldn't see how to use Global Actions for this use case either.

Opportunity Report (Classic): /00O0J000009uZUR?pv0={!Opportunity.Id}

Opportunity Report (LEX): https://eu7.lightning.force.com/one/one.app#/sObject/00O0J000009uZURUA2/view?a:t=1487763110469&fv0={!Opportunity.Id}

I used the new '&fv0=...' functionality in Spring '17 for the LEX link (https://resources.docs.salesforce.com/206/latest/en-us/sfdc/pdf/salesforce_spring17_release_notes.pdf - search the pdf for fv0)

Downsides are - it seems you have to provide the full url for the LEX link, so if the org is migrated to another instance it will break. - you have to click an 'ok' button to authorise the redirect in LEX

If you are in Classic, both links work. You get the LEX report from the LEX link.

If you are in LEX, the Classic link gives you an empty report. The LEX link gives you LEX report, but only after clicking 'ok' button.

  • Gah, that's really awkward. Maybe acceptable if you could create a different page layout for Lightning Exp vs Classic, but I'd rather just have the custom links be defined once and be interoperable between the two modes. Would custom quick actions be an option? These would show up as buttons unfortunately but maybe there's a way to navigate to the report with the URL hacks applied that's safe for both modes? – Stephen Feb 24 '17 at 16:16
  • EDIT: sorry, you already mentioned global actions not being a fit – Stephen Feb 24 '17 at 16:56
  • Another possible option: The Lightning event "force:navigateToSObject" can take you to a report page by passing the id, but there's no options for URL params. But with "force:navigateToURL" you could build a link to your report potentially? I did a (very quick) experiment and from within Lightning Exp, this seemed to work (you can drop the "at" bit): sforce.one.navigateToURL('/one/one.app#/sObject/[url to report]/view?fv0=[filter value to use]'); It didn't seem to work in the SF mobile app though. – Stephen Feb 24 '17 at 17:13
  • To clarify: SF mobile navigated to the report, but didn't apply the filters, but for desktop it worked. I was thinking of using this within a custom lightning component that would render the links to your reports and use force:navigateToURL to build a link to the report + the filter values. This wouldn't be interoperable with Classics's custom links, unfortunately. – Stephen Feb 24 '17 at 19:11
0

This guy seems to have figured out how to get the report to work:

http://biggerboatconsulting.com/supporting-report-filter-url-hacks-in-lightning-and-classic/

  • 1
    Hmm, Beth is not a "guy" – JodieM Aug 31 '17 at 4:44
0

I was having issues with this as well! Depending on how complex your URL is, I was able to get around this by adding another tab to the Lightning page and adding report charts that are filtered on the record ID. This worked really well, but only if you are passing the ID through and nothing else.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.