How to display links in the email body as a clickable hyperlinks instead a plain text in description

Ankit Dubey5
Kilo Guru

Problem: At present, when a request is initiated through inbound action, the email body is captured within the description field in text format. However, it's noteworthy that URL links within the email body are currently stored merely as text. As part of enhancing user experience and functionality, there is a need for these URLs to be rendered as clickable hyperlinks for ease of navigation and efficient access to pertinent resources.

 

Ask: URL links found within the email body stored within the description field, rendered as clickable hyperlinks to ensure seamless access and navigation for users.

 

Solution:

 

1. Create a new HTML type field label as Detailed Description or as per business needed 

2. inbound action needs to be modified using the below script 

 

 

 

function convertURLsToLinks(text) {
    // Regular expression to find URLs within the text
    var urlRegex = /(https?:\/\/[^\s]+)/g;
    
    // Replace URLs with clickable links
    return text.replace(urlRegex, function(url) {
        return '<a href="' + url + '">' + url + '</a>';
    });
}


var emailBody = email.body_text;
var convertedEmailBody = convertURLsToLinks(emailBody);

 

 

 

 

AnkitDubey5_0-1712003051522.png

 

1 REPLY 1

DrewW
Mega Sage
Mega Sage

This is one way you could do it.  Another way is to take the HTML body and post it into the work notes field with "[code][/code]" tags around it rather than create another description field.  And yes I used [] on purpose.