I have portals configured for dev, test & prod environment. I need to send a portal link (e.g. https://<portalurl>/?<recordid>) of a record in an email via workflow. The portal url is different for all the environment.
How will I add the portal url dynamically in the email so that it redirects to the correct portal url i.e. dev, test * prod?
Exactly what I'm after too.
I did similar thing for a customer. Where in on load of an new email record, I was applying predefined templates with tags. All using JS. Once are in onload you can get the template and replace the tags with the Dynamic Portal URL (this you can get from config or similar). Template then can be applied to Email record.
I am sure you will get the desired result.
I suggest creating a custom workflow that retrieves the "primary domain" field from the Website entity, this custom workflow can have an output parameter that you can use in your workflows
If you email somehow connected to website, you can use website.adx_primarydomainname as had been already suggested.
But most clean way will be to write custom action (plugin) to return this url from the active bindings for required website. Because primary domain can be not the most relevant (especially if you migrate web sites between environments), or site can has multiple domains.
There are other options to use "site settings" entity, "settings" entity or custom similar entity
Business Applications communities