1

Our Salesforce Org is moving from na6 to na70 I have been trying to find a way to convert this:

<img src="https://c.na6.content.force.com/servlet/servlet.ImageServer?id=12345678" alt="Get Support"/>

I could just replace the na6 with na70, but I wonder if there is a better way, by using mydomain or even by having a dynamic link. (i.e. /12345678).

Thank you for reading.

1

2 Answers 2

3

You can set the url dynamically by using the getSalesforceBaseUrl() method in the URL class. This will always get the current instance for the org so you don't have to manually update it each time.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_url.htm

1
  • I did see this, but was wondering if there was another easier option, like a global variable that could be used directly from visualforce without the need of a class and test class.
    – MicroSumol
    Commented Oct 6, 2018 at 21:23
2

If you're using My Domain, you'll get a different URL, which looks like this:

https://mydomain.documentforce.com/servlet/servlet.FileDownload?file=123456

You can hardcode this URL, because it will never change despite moving from one pod (instance) to another.

3
  • I have tried this but it is not working for content.force.com. Are you able to show a screenshot of it working for you?
    – MicroSumol
    Commented Oct 7, 2018 at 13:19
  • 1
    @MicroSumol phyrfox-dev-ed--c.documentforce.com/servlet/…
    – sfdcfox
    Commented Oct 7, 2018 at 14:10
  • @sfdcfox amazingly that link still works lol
    – zaitsman
    Commented Aug 14, 2019 at 5:36

You must log in to answer this question.

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