Find your content:

Search form

You are here

How do I get the base URL in the formula editor?

 
Share

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?


Attribution to: Daniel Hoechst

Possible Suggestion/Solution #1

This will give you the Base URL

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

Attribution to: techtrekker

Possible Suggestion/Solution #2

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.

Attribution to: Andrew Fawcett

Possible Suggestion/Solution #3

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:

https://na9.salesforce.com/00T/e?what_id=001E000000XXXvC&retURL=%2F001E000000XXXvC
&tsk6=Account+Name&tsk5=Account+Name

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

https://na9.salesforce.com/00T/e?what_id={!Account.Id}&retURL=%2F{!Account.Id}
&tsk6={!Account.name}&tsk5={!Account.name}

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
?what_id={!Account.Id}&retURL=%2F{!Account.Id}&tsk6={!Account.name}&tsk5={!Account.name}

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

/00T/e?what_id={!Account.Id}&retURL=%2F{!Account.id}
&tsk6={!Account.name}&tsk5={!Account.name}

Attribution to: Ralph Callaway
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/3816

My Block Status

My Block Content