Wednesday, February 20, 2013

How to implement a 'MailTo' Link (html format) in a calculated Column in SharePoint List

For example if you want to show an email link if the category (another column value say AppType) is 'On-Request', and by clicking on that you can open an outlook window to send a request email. 
But you don't want to show the full 'href' link instead just a text "Request" with an html link that will trigger the email. In that case you can use the following method. 

Create a calculated column (say 'Request' for request email). 

Add a content editor web part to the list page and add the following JavaScript. 

<SCRIPT type=text/javascript>
if(typeof jQuery=="undefined"){
var jQPath ="";
document.write("<script src='",jQPath,"jquery.min.js' type='text/javascript'><\/script>");

<SCRIPT type=text/javascript>
var tempDIV = document.createElement ("DIV"); = "pointer";
tempDIV.innerHTML = $(this).text();

Now give the following code as value for the calculated column you created: 

=IF([App Type]="On-Request","<DIV><a href=''>Request</a></DIV>","")

Now you can see column values as html links. 
The JavaScript function will convert the text to html wherever it finds the 'DIV' tag.