I'm building a custom button that when clicked creates a task. In the task comments, I'm building a URL to direct the assignee to the Account Team add page. I need to know the instance I'm on in order to build the button properly.

Is there a way to get the base url (https://na6.salesforce.com) or instance (na6) in the formula builder so I can avoid hardcoding an instance?

  • Can you tell us more about what it is your referencing? Commented Oct 29, 2012 at 16:03

3 Answers 3


This will give you the Base URL

LEFT($Api.Partner_Server_URL_260, FIND( '/services', $Api.Partner_Server_URL_260))
  • Thanks, I didn't think of substringing the $Api.Partner_Server_URL_260. Commented Oct 29, 2012 at 16:59
  • Glad it helped :) Commented Oct 29, 2012 at 18:52
  • @techtrekker how could add it as an hyperlink in Flow's Custom Notification body ?
    – Cline
    Commented May 5, 2022 at 21:52

In almost all instances you shouldn't need the instance base url to make a custom button. APEX has very recently added functions to get this programmatically. And as @techtrekker points out you can also get it in the formula field.

Let's say you're on the na9 instance and you want a custom button to create a task from an account for the subject and comments. You'd end up at this url when you create a task using the regular new task button for an account:


To make this into a custom button you could code hard code the instance like this:


Or use the api partner url to add the instance dynamically:

LEFT($Api.Partner_Server_URL_260, FIND( '/services', $Api.Partner_Server_URL_260))/00T/e

But why not just avoid the issue and not specify the instance entirely:

  • 1
    I'm doing this for the button. The problem is that I need a link in the comments of the task being created. Commented Oct 30, 2012 at 14:19
  • Ahh, gotcha. @techtrekker has what you need then Commented Oct 31, 2012 at 2:18
  • 1
    To answer your last question... If formula is a field (using HYPERLINK function) in an object and you subscribe to a report containing that field, the hyperlink won't know the right domain to sub in for for your referential link when you get the email containing it. Happy to learn the api partner url trick! Commented Apr 19, 2019 at 20:01

If it's a resource relative to your org, you should not need to use fully qualified URL's generally.

  • I don't see any $ vocabs you can use for this (thought the $Api.Partner_Server_URL_260 one might be of use to extract what you need using the TEXT formula functions).
  • You can also use methods on the URL class to get this, getSalesforceBaseUrl. So it maybe be possible to point your button or formula to a page that then uses this and redirects further.
  • The link is getting added to the comments of a task, so I need the full URL. I'm trying to avoid creating code. Commented Oct 29, 2012 at 16:28
  • Ah I see, what is it a link to if you don't mind me asking? Trying to figure out a way (different question I guess) to allow you to link from here to the target without fully qualified.... Commented Oct 29, 2012 at 16:58
  • I'm linking to the Account Team add page. We keep Accounts private unless you are on the Account Team. There is a public directory object we have. The goal here is to have a button on the directory record so someone can request being added to the Account Team. The button creates a task with a prebuilt URL that passes everything to the Account Team page. Commented Oct 29, 2012 at 17:01
  • I see, i guess the issue is it is not dynamic if Salesforce actually splits your org to an another instance in the future and your links break. That said, I guess if its Tasks the links are embedded on you don't really care so long as the task is done by then. :-) Anyway you seem to have your answer, above, thanks for the chat! Commented Oct 29, 2012 at 17:20

You must log in to answer this question.

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