I wanted to display the people picker value in a list form as a hyperlink in SharePoint. By default, it was just a text field on the display form. In a normal SharePoint list form, this field can be modified to disable output escaping so that it formats as an html. I was totally unsure how to accomplish this, and pressed for time, I decided to write a script to format it as a hyperlink. If you know how to do this in InfoPath, please share!
Place this script in a content editor webpart on the display list form:
Place this script in a content editor webpart on the display list form:
<script type='text/javascript' src='/js/jquery-1.7.2.min.js'></script> <script type="text/javascript"> //make sure document is loaded first $(document).ready(function() { setTimeout(formatUserField,'1000'); }); function formatUserField() { $("span[ScriptClass='CustomControl']").each(function(){ var curValue = $(this).text(); var newhtml = "<a href='javascript:void(0)' onclick='PopUpEmail(\"" + curValue + "\");return false;'>"+ curValue +"</a>"; $(this).html(newhtml); }); } function PopUpEmail(username) { var p_recipient = username; var p_cc = ""; var p_subject = ""; var p_body = ""; var objO = new ActiveXObject('Outlook.Application'); var objNS = objO.GetNameSpace('MAPI'); var mItm = objO.CreateItem(0); mItm.Display(); mItm.To = p_recipient; mItm.Cc = p_cc; mItm.Subject = p_subject; mItm.Body = p_body; mItm.GetInspector.WindowState = 2; } </script>
No comments:
Post a Comment