+ Start a Discussion
Karna_ShivaKarna_Shiva 

How to put URL dynamically in HTML email template

How to put URL dynamically in HTML email template, i want to populate url dynamically otherwise on every instance i have to chance the URL.

Some one please suggest me what we have to do here.
Mahesh DMahesh D
Hi Karna,

There is an idea on this topic, please vote for it.

https://success.salesforce.com/ideaView?id=08730000000b3PjAAI



There is a workaround for that... you can create a formula field of type text and insert the following:

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

That will give you the ORG''s URL ... than let's Say that you have created the formula field above with the name of "ORG URL",  so you can type in on the template the following:

<a href={!YourObjectName.ORG_URL__c}/{!Opportunity.Id}>{!Opportunity.Name}</a>

Just make sure you replace the YourObjectName with the name of the object where you are running the workflow... so if you need to link it into another object via the lookup relationship you can get the ORG URL field that you created and merge with the ID of that object to put the link together. 

-------------------------------------

Also look into below posts:

https://developer.salesforce.com/forums/?id=906F00000008mLsIAI

http://salesforce.stackexchange.com/questions/33035/adding-link-to-a-related-record-in-html-email-template

http://salesforce.stackexchange.com/questions/68988/dynamically-generated-link-in-an-email-template

https://success.salesforce.com/answers?id=90630000000gjpYAAQ

https://developer.salesforce.com/forums/?id=906F00000008mzFIAQ

https://developer.salesforce.com/forums/?id=906F00000008n2iIAA

https://www.shellblack.com/administration/create-a-html-email-with-merge-fields/


Please do let me know if it helps you.

Regards,
Mahesh
Mark RootMark Root
Here's what I ended up doing, using the standard "Link" field that comes with whatever record you're working with:
{!MID(Task.Link, 1, LEN(Task.Link)-15)}{whatever_you_want}

In my case, this produced:
https://marine-dev-ed.my.salesforce.com/{whatever_you_want}

No need for a custom field, custom label, custom setting, or apex.
Sanjay Thakur 21Sanjay Thakur 21
Hi Mark,
This works for me
{!MID(User.Link, 1, LEN(User.Link)-15)}{!Target_User.Id}
Thanks
Jithesh VasudevanJithesh Vasudevan
Brilliant. Thanks so much Mark Root and Sanjay Thakur. Your answer should be selected as the best answer. This totally works.
Bablu Kumar PanditBablu Kumar Pandit
Hi @Mark Root,

I need task Record Link so can you plz help me i am using {!MID(Task.Link, 1, LEN(Task.Link)-15)}{!Task.Id} in href tag but it is not working for me.plz let me know how do i used to get proper URL.
Mark RootMark Root
That should just be {!Task.Link} then, nothign else.
Ashutosh Mishra 18Ashutosh Mishra 18
Hi @Mark Root,

Could you please help me in getting Opportunity Link, using the Case Record. I tried different ways but not able to get Oppotunty Link using the Custom Look-up fields on Case Object

Thanks in Advance,
Ashutosh Mishra
Mark RootMark Root
Is the API name of your Opportunity field on Case something like "Opportunity__c"? If so, your email template link would look something like this: {!MID(Case.Link, 1, LEN(Case.Link)-15)}{!Case.OpportunityId__c} Mark.