I have a Home Custom Link Url like this: {!$Site.OriginalUrl}/00O5B000000OL93 that points to a report. I need to be able to change that hardcoded ID with something that won't break once I deploy this to different Sandboxes or Production . What do you guys recommend?

3 Answers 3


I believe the only way to to it would be to use a VF page as the Link and use an action method to navigate to the report.

In the VF page controller query for the report by name:

 <page name="reportRedirect" controller="controllername" action="{!gotoReport}">

    .......No content needed here unless you want it like a waiting spinner or something .....


public pageReference gotoReport(){

    Report[] rpt = [Select Id, Name From Report Where Name = 'XYZ'];
    if(rpt.isEmpty()) return null;//Error handling here. Maybe show something on page

    PageReference pr = New PageReference('/' + rpt[0].Id);
    return pr;

  • If you use this solution, I think it is rather important to filter by FolderName, as well. I'm not sure if DeveloperName is unique outside of a folder. Commented Mar 29, 2017 at 15:38
  • @CharlesKoppelman - Good point, not sure either.
    – Eric
    Commented Mar 29, 2017 at 15:40
  • @Eric the DeveloperName is not unique but for now, that'll fix the "issue". Thanks Eric and thanks Charles!
    – The Ghost
    Commented Mar 29, 2017 at 18:36

There are two ways I'd answer this question, but both are pretty terrible.

  1. Deploy the report first, then refresh a Sandbox. Your report's Id won't change.

  2. Deploy a Custom Setting that you manually update on deploy to production. You can automate the "manual" update as much as you'd like.

These only work if you have exactly one production org. If you develop for multiple orgs, you'll probably be best either automating #2 on install of your package using the now-famous mdapi package from FinancialForce, or use Eric's solution.

I suggest Custom Settings and not Custom Metadata because we cannot yet access Custom Metadata in formulas.


If it goes to an internal SF report why not make it just /00O5B000000OL93? It's a relative link and Salesforce will fill in the appropriate before parts so it can be dynamic between production and sandbox.

  • 1
    The point is that Ids don't migrate...
    – Adrian Larson
    Commented Mar 29, 2017 at 15:30
  • @AdrianLarson Is that true if you are deploying using the Metadata API to deploy from a Sandbox to Production? Is that true if you're using a Changeset to deploy from Sandbox to Production? Commented Mar 29, 2017 at 15:43
  • 1
    That is true in both cases. Ids are only identical at the instant when you refresh a Sandbox from its parent. Immediately after that, the Ids diverge again. Commented Mar 29, 2017 at 15:45

You must log in to answer this question.

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