0

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?

0

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.

| improve this answer | |
  • 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 Jun 6 '18 at 10:37
  • @rakesh As I said, the object is queryable by all users. – sfdcfox Jun 6 '18 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 Jun 6 '18 at 10:41

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.