SharePoint Library - Calculated Column- want to find current url of folder

Hey Everyone,

I've run into an issue where the previous admin created a calculated column in a content type that is used by over 100 sites. The calculated column works properly, except for the fact that in this Library, folders aren't able to open.

The calculated column's formula uses document ID's but as we know folders don't have document IDs.

That being said, when trying to open these folders by clicking within the column, throws an error.

The code below is the calculated column's formula

="<script type='text/javascript'>"&"	var buildURL = '/_layouts/DocIdRedir.aspx?ID="&[Document ID Value]&"';"&"	var target = '_blank';"&"	var innerHTML = '<a href=' + buildURL + ' target=' + target + '>"&Title&"</a>';"&"document.write(innerHTML);"&"</script>"

I believe this below is a good start, but I am at the point where I need to change the URL - to some script that pulls the folder URL.

=IF(ISBLANK([Document ID]),"<a href='http://site/library/"&Title&"'>"&Title&"</a>","<script type='text/javascript'>"&"var buildURL = '/_layouts/DocIdRedir.aspx?ID="&[Document ID Value]&"';"&" var target = '_blank';"&"var innerHTML = '<a href=' + buildURL + ' target=' + target + '>"&Title&"</a>';"&"document.write(innerHTML);"&"</script>")

Thanks to Thriggle https://social.technet.microsoft.com/profile/thriggle/?ws=usercard-mini

for coming up with this code.

Can someone please help?

August 20th, 2015 2:18pm

Hi Marc,

I recommend to create a list workflow which is associated with the library to update Title column with the Name field and set the workflow to start when an item is created.

And then you can construct the URL with Title column in the formula as you said in your post.

Best regards,

Victoria

Free Windows Admin Tool Kit Click here and download it now
August 21st, 2015 11:14am

Hey Victoria,

I understand the directions you provided. But I'm not sure what the results will be. Will this resolve the folders not being able to open?

Will this work for all the sites that use this content type?

Thanks!

August 21st, 2015 1:48pm

Hi Marc,

The workflow I suggested can help you to get the URL of the folder.

And workflow is a list workflow and it only works for that list/ library.

Best regards,

Victoria

Free Windows Admin Tool Kit Click here and download it now
August 24th, 2015 12:27am

Hey Victoria, 

Thanks for the response. 

I want to apply this to 100+ sites, because the column is in a content type that is applied to these sites.

Is there any other way?

August 24th, 2015 9:59am

Hi Marc,

If you want to apply this to multiple sites, I recommend to create a item added event receiver for document library to update the Title field with the Name field.

You can create a farm solution for this to make it work for all sites if you active the feature on the sites.

Best regards,

Victoria

Free Windows Admin Tool Kit Click here and download it now
August 24th, 2015 11:19pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics