How to Get Salesforce Org (not Community) Base URL in Flow used in Experience Cloud

There is a requirement to generate a salesforce org record link dynamically in Flow, while the flow is used in a digital site (Salesforce community), but the base URL has to be Salesforce org base URL, not the community site one.

I tried using URL.getSalesforceBaseUrl() .toExternalForm() in a apex action to do a lookup or using a system variable {!$Api.Enterprise_Server_URL_550} in a flow formula, but all of them can only give me the community base URL, in my case, I want to avoid using any Apex actions and I need a Salesforce org URL.

With Enhanced Domains enabled, it all becomes very easy, the community base URL should look like https://YOURDOMAIN.my.site.com, I need to replace site.com with salesforce.com, then I have my Salesforce org base URL: https://YOURDOMAIN.my.salesforce.com

LEFT({!$Api.Enterprise_Server_URL_550}, FIND('site',{!$Api.Enterprise_Server_URL_550})-1) & 'salesforce.com/' & {!YOUROBJECT.Id}

For more information about how to replace the first substring of a string, please check out https://jmcloudservices.com/blog/replace-the-first-substring-of-a-string-that-matches-the-search-term-or-expression-using-salesforce-formula

If you have any questions or suggestions, please feel free to contact me.

Previous
Previous

How to replace hardcoded Ids in Metadata during a deployment using SFDX

Next
Next

Adobe Sign Agreement Status not Updated Errors in Salesforce