Change hyperlink field value from http:// to file:// on a form

On list forms, SharePoint offers a lot of fields Out-of-the-Box plus you are free to create your own custom fields to accommodate requirements and customer data types.

Among the OOTB fields is the hyperlink field which requires either http or https.  Sometimes you want a link to a file somewhere (such as a shared drive) for which there is a UNC path but no http path.  We will use JQuery to convince SharePoint to accept UNC path names in the hyperlink field.  Lets jump into the topic right away.

Step 1: Add a new hyperlink column to your list. Name the hyperlink field as “testhyperlinkfield” or name it whatever you are comfortable with.

Field Name giving

Step 2: Download the necessary supportive Jquery library files from the internet and upload them to your Site Assets folder.

I have addded the files that i had used during my development. You can also download the latest files from the following site (http://jquery.com/download/)

jquery.SPServices-0.7.2

jquery-1.10.2.min

jquery.SPServices-0.7.2.min

 

Step 3: Open notepad and add the below lines of code and save the file as “hyperlinkrootchanger.txt

<script src="http://ServerName/sites/SiteName/SiteAssets/jquery-1.10.2.min.js"></script>
<script src="http://ServerName/sites/SiteName/SiteAssets/jquery.SPServices-0.7.2.min.js"></script>
<script src="http://ServerName/sites/SiteName/SiteAssets/jquery.SPServices-0.7.2.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("INPUT[title='testhyperlinkfield']").val('file://');
});
</script>

P.S. Remember to change servername and urls according to your server details

Step 4: Now upload this text file to your SiteAssets library. Copy the url of the location where the file is saved.

Step 5: Now navigate to your list and type the following in the url bar.http://Server Name/Lists/List Name/newform.aspx?PageView=Shared&ToolPaneView=2 the page that opens will enable you to add a web part. Add a content editor web part to this page. Now edit this webpart’s properties where in the “Content Link”  property give the location of where you saved the java script text file initially in the site assets library. once this is done, click on Apply and Ok button.
 
content link property
Now open the newform.aspx or try to open a new list item page and you should see the changes like shown below:final hyoper link root value changer

Happy Jquery scripting !!

Guru

Digiprove sealCopyright secured by Digiprove © 2014 Douglas Spicer