Getting the Root URL in a Formula Field



If you're dynamically constructing a URL in a formula field, you can use the following for the root:

left($Api.Enterprise_Server_URL_500,find(".com",$Api.Enterprise_Server_URL_500)+4)

That will give the base URL regardless of whether you're in a sandbox or production. For example, it will give:

https://myorg--usertest.sandbox.my.salesforce.com in a sandbox, or

https://myorg.my.salesforce.com in production

Easy peasy. Don't hard-code URL's!

Comments

Popular posts from this blog

Setting a DateTime to a Weekday in a Formula

"Disjunctions not supported" - Why Custom Metadata and Flow Don't Mix

Update Knowledge Articles in Bulk