CRM 2011: change format of textfield to hyperlink
A customer asked me to change a single line text field to a hyperlink. As we know or as you have found out. It’s not possible to change the formatting of fields. Personally I think this is something which should be available. Maybe something for the next Dynamics CRM release?
Anyway, I had some options
1) Create a new field with hyperlink formatting, make sure the data is copied from the old field to the new, delete the old field -> Too much work
2) Create a new field with hyperlink formatting, create a jscript that copies over the data –> Not too much work, but there has to be something else, right?
After some googling I found this URL: http://mscrmkb.blogspot.be/2012/01/convert-text-field-to-link-button-to.html (ALL the credits go to this person, this blogpost is more like a personal note).
This script will convert your field to a link button, how cool is that? Here is the script I used:
function ConvertToLink(fldName) { if(Xrm.Page.getAttribute(fldName).getValue()!=null) { var content = Xrm.Page.getAttribute(fldName).getValue(); var btn = "<a href='javascript: void(0);' onclick=\"window.open(\'"+content+"', \'windowname1\', \'width=600, height=650\'); return false;\" style='color:blue;text-decoration: underline !important'>"+content+"</a>"; var ctrl = Xrm.Page.ui.controls.get(fldName)._control; // Add the new button ctrl.get_element().innerHTML += btn; // Hide the textbox ctrl.get_element().firstChild.style.display = 'none'; } }