In Spring' 18 release, Salesforce has introduced critical update "Remove Instance Names From URLs for Visualforce, Community Builder, Site.com Studio, and Content Files". This update removes the instance name (ex. na15) from url.

We were getting instance name by parsing URL.getSalesforceBaseUrl().toExternalForm() in apex code of Visualforce Page. But, after activating critical update, my code breaks because I am no longer able to get instance name.

I googled this problem and found that we can query "Select InstanceName from Organization" to get instance name. But I am not sure which minimum permission or which other considerations are required to query Organization object. So, is there any other better approach to get instance name?

1 Answer 1


The Organization object is queryable by all users, even Guest Site Users, so you should be okay using that technique. If you're still uncertain, you could always put the query inside a "without sharing" class to make sure you have access to the object.

  • Thank you for the reply. I am using "with sharing" class and have written code to query Organization object. So, will it create any issue?
    – rakesh
    Commented Jun 6, 2018 at 10:37
  • @rakesh As I said, the object is queryable by all users.
    – sfdcfox
    Commented Jun 6, 2018 at 10:39
  • Ok. Got it. I have verified that I am able to query Organization object. I was concerned because somewhere I have read that it required "View All Data" permission.
    – rakesh
    Commented Jun 6, 2018 at 10:41

You must log in to answer this question.

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