Monday, May 14, 2012

Displaying Notes Link as Hyperlink in SP Field..!


Steps to follow for showing Notes Link in All Items Page of a List:
        
1.     Create a “Single Line of Text” column for notes URL.  e.g. “Notesurl” (Migrate the notesurl field into this text field).
2.     Create a calculated column with the formula –    
 =“<a href=’” & Notesurl & “’>”& Notesurl & “</a>”         
3.     Create a document library to hold attached jquery script file (jquery-1.3.2.min.js). -- Link to Jquery File jquery-1.3.2.min
                                           
4.     In  “Allitems.aspx” page -> Add a CEWP below the list view with the code mentioned code from Notes Link Script.  
Notes Link
Showing Notes Link Display form of an item in list:
          To Show same link in DispForm.aspx – add CEWP (Content Editor Web Part) below list web           part and add the content mentioned as below. 
1.      <script type="text/javascript" src="<Path Of Jquery file>">
2.      </script>
3.      <script type="text/javascript">
4.      fields = init_fields();
5.      // This is an array of FieldInternalNames for all fields to reformat
6.      var arrOfFieldsToReformat = ['LinkCol];
7.      // Loop trough all fields in array and reformat to decent link
8.      $.each(arrOfFieldsToReformat,function(idx,item){
9.         var LinkField = $(fields[item]).find('.ms-formbody');
10.     LinkField.html(LinkField.text());
11.  });
12.  function init_fields(){
13.  var res = {};
14.  $("td.ms-formbody").each(function(){
15.  if($(this).html().indexOf('FieldInternalName="')<0) return;
16.  var start = $(this).html().indexOf('FieldInternalName="')+19;
17.  var stopp = $(this).html().indexOf('FieldType="')-7;
18.  var nm = $(this).html().substring(start,stopp);
19.  res[nm] = this.parentNode;
20.  });
21.  return res;
22.  }</script>
Note: In line 6 you must insert your own FieldInternalNames! You can add multiple FieldInternalNames, comma separated.
This will result in a DispForm like this:
Notes Link In Display form

No comments:

Post a Comment