-1

Is there a way to create a relative URL link to a report? For example, a link that would be valid in test, QA, and prod. Since the report ID would be different in each environment, would need a way to find the specific report without the report ID, such as by report name. So, two requirements:

  1. relative URL link, and
  2. to a report using non-ID value, such as report name. Suggestions? Thanks!
2
  • 1
    Welcome to SFSE. Please take a moment to read How to Ask and take the tour. Have you looked into Custom Settings or Custom Metadata Types? Apr 6 at 20:31
  • Use CMDT to save the report Developer Name and then query for the Id
    – cropredy
    Apr 6 at 22:15

1 Answer 1

0

You would need some code to help you, but the level of effort is trivial.

<apex:page controller="ReportRedirectController" action="{!redirect}"></page>
public class ReportRedirectController {
    public ApexPages.PageReference redirect() {
        String reportName = ApexPages.currentPage().getParameters().get('report');
        Report r = [SELECT Id FROM Report WHERE Name = :reportName];
        ApexPages.PageReference ref = new ApexPages.PageReference(Url.getSalesforceBaseUrl().toExternalForm()+'/'+r.Id);
        ref.setRedirect(true);
        return ref;
    }
}

Now, you can use it anywhere Visualforce is valid, with a URL like /apex/Report?report=Name+Of+The+Report.

Error handling and unit testing is left as an exercise to the reader.

You must log in to answer this question.

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