Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I'm building Pages and Links that should point to SF reports, and ideally would continue pointing to the right reports after deployment, without manually updating all of the report IDs. Is there an equivalent of URLFOR for reports that I can use to reference reports by DeveloperName instead of ID?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

To build slightly on Mikey's answer:

I have done exactly as he suggests, except that it exists as a standalone VF page. The sole purpose of the page is to redirect to a report. Thus you can embed a link to this page anywhere in salesforce instead of linking directly to a report and it will redirect to a report based on name.

This avoids the need to embed the logic into each individual VF page, and it can be used from Custom Buttons/Links, Formula fields, etc.

e.g. To specify a link to the Report "Executive Accounts Summary" with the Id 00O400000033vc5.

Normally you'd use: /00O400000033vc5?pv0=...

Instead now you use: /apex/reportlink?name=Executive_Accounts_Summary&pv0=...

share|improve this answer

If you're using a Custom Apex Controller or Extension to build your page, this is as simple as querying the Report object. Error handling left off for brevity, but a simple example:

Id reportId = [SELECT Id FROM Report WHERE DeveloperName = 'Foo'].Id;
String reportURL = URL.getSalesforceBaseUrl().toExternalForm() + '/' + reportId;
share|improve this answer
    
That's true. Any thoughts on doing this w/o custom Apex? –  Benj Feb 22 '13 at 14:25
    
@Benj I can't think of anyway to achieve without Apex. What's the scenario for trying to achieve it without Apex? If you're trying to render this on a Visualforce page, a custom controller or extension would only require a little code. –  Mikey Feb 22 '13 at 15:48
    
@Benj, apex is going to be the only way to get the id of the report. –  Ralph Feb 22 '13 at 16:13
    
@Ralph, my interim solution was doing this in a component so that I could just write the report name in the VF page, but that makes n queries for n reports, which is sad :( –  Benj Feb 26 '13 at 19:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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