Select a view for Document Library web part

April 23, 2008

With MOSS 2007, after inserting a document library web part, you can select a specific view to use for this web part (same for other list web parts).

However I found that once the web part is created, the changes made to that view will not be automatically reflected in the web part. You have to go back to the edit properties window of the web part and re-select the view. It looks like the web part creates a local “instance” of the view definition.


Got javascript error after enabled Content Type

April 11, 2008

I created a few customized Content Types in the site and enabled “Manage Content Types” in document library. Now when user creates new files from the template and save it, a javascript error will pop up in DIP window: “‘length is null or not an object”.

Microsoft confirmed it’s a SharePoint bug and now finally have a hot fix: http://support.microsoft.com/default.aspx?scid=kb;EN-US;950292

However this hotfix requires SP1 and another post-SP hotfix. Not only that, it’s not an officially released hotfix (that’s why you have to request it in another web page), which means it not 100% tested.

There are many people frustrating about it and have some workaround. Unfortunately none of them work for me because Content Types is in our business request.

Another thing is once the Content Type is enabled, this problem will be permanent even Content Type is turned off later. Seems turning on Content Types has permanent change on the document library, even no document is created from the new content type.


Free up Database space after deleting documents

March 28, 2008

In a Document Library of SharePoint 2007, deleted documents will be put on Recycle Bin first (this is the default setting). SharePoint Recycle Bin works similarly to Windows one – user has their own recycle bin and one can not see others. Items in recycle bins will be permanently deleted after 30 days.

You may want to free up some database space by emptying your recycle bin, but it won’t work. If you check database tables, you will find that the records are still in [AllDocStreams] table and the database size is even bigger (because of transaction log). What if you want to get rid of the junk (i.e. you want to back up the current site)?

Log in as site administrator and click on “Recycle bin” under “Site Collection Administration” section. Click on “Deleted from end user Recycle Bin” view on the left, and delete the items there. This time the database records will be really deleted.

This “double” recycle bin might come to handy when someone mistakenly delete items from his/her recycle bin.  Do not like it? You can turn this feature off in Central Admin site. In Application Management->Web Application General Settings page, turn off the “Second stage Recycle Bin”. You can also turn off the whole recycle bin or change settings here.


IE crashes when opening office document from SharePoint

March 20, 2008

Suddenly, my IE crashes when I open any Office document from SharePoint document library. It turned out to be a component in Office 2007 causing this, even I only have SharePoint Designer installed. Microsoft has a fix: http://support.microsoft.com/kb/938888. It worked.


Send To->Email a Link doesn’t work

March 12, 2008

In SharePoint 2007′s Document library, the Send To->Email a Link context menu will open your local email client and put the link of that document in the email body. However, it seems URL encode the whole URL, instead of just the relative path.  So the URL will end up like this:

 http://subdomain%2Ecompany%2Ecom/Documents/folder/subfolder/My%20File.doc

Basically, the dot (.) in the domain name is also URL encoded (%2E). If you copy and paste it to IE it will still load, but clicking it from Outlook doesn’t work.

To fix it, open CORE.js from  \12\TEMPLATE\LAYOUTS\1033, fine this line:

 fileUrl=escapeProperly(httpRootWithSlash.substr(0, slashLoc))+currentItemUrl;

and replace it with this:

fileUrl=httpRootWithSlash.substr(0, slashLoc)+currentItemUrl;

I found OWS.js (in same folder) also have this. But changing CORE.js alone will fix it. I don’t know what’s the difference between these 2 files.


<link rel=File-List href=”[your file name]_files/filelist.xml”>

January 9, 2008

This isn’t actually for SharePoint though.

When Microsoft Office saves file as HTML, it puts all real files under xxx_files. More on here: http://sharemypoint.wordpress.com/tag/_files/

When you try to rename/move/delete the root file, the associated _files folder will be changed accordingly. The key is in this line in the root file

<link rel=File-List href=”[your file name]_files/filelist.xml”>

If this line is removed, Windows Explorer will give you a warning only and won’t automatically move the _files folder.

This trick is useful for me when I need to rename the HTML root file. Otherwise, SharePoint will give you error message saying you can not rename the “thick” file (_file folder).


Undocumented path length limit when opening in Explorer view

January 3, 2008

In SharePoint 2007, there are 2 ways to open a folder in Explorer view, in the Actions menu, or through the ‘Explorer view’

explorerview1.jpg

Or

explorerview2.jpg

However, if you are at a very low level folder and the path of the folder is more than 100 characters, you will get this error message:

explorerview3.jpg

I drilled down with the client code and found that it’s because of a Microsoft IE API (httpFolder.navigateFrame) that used by SharePoint (NavigateHttpFolderCore() function in \12\TEMPLATE\LAYOUTS\1033\Core.js) that has the 100 characters limit on the web address (including the starting http://).

The workaround is that users goes to top level folders to open it Explorer view, then navigate to the folder they want to go. When they navigate through the folders within Explorer View, there is no limit on the folder path length.


Automatically checkin files after uploading

December 20, 2007

In a typical document library of SharePoint MOSS2007, when use “Upload Multiple Files”, or use drag & drop in Explorer View, you can upload multiple files or folder easily. However sometimes the files are kept in “Checked out” mode and will not be available for others until they are checked in. Unfortunately SharePoint doesn’t have a “bulk check-in” function. So how do you have the files automatically checked in?

The key is in the setting “Require documents to be checked out before they can be edited” – this has to be “No”. Change it through “Document Library Settings”->”Versioning Settings”. The option is at the bottom.

Another setting that could prevent files to be auto checked in is the required columns. Make sure you turn off all mandatory columns, or give them a default value.

Other settings in “Versioning Settings” (such as Content Approval, version numbers etc) do not matter.


Barcode

August 7, 2007

A good intro from blog.microsoft.com: http://blogs.msdn.com/recman/archive/2006/08/10/694087.aspx

After bar code policy is removed, the new files will not have bar code generated. But the existing ones will still keep the bar code values. The ‘View Properties’ window will still show the bar code image.

Customized barcode generator (sample here) indicates that barcode generator does NOT take any input parameter. So it’s impossible to embed any specific information about the target.


Links feature in SPFile

August 1, 2007

This MS internal document can serve as a good overview of the SPFile link management feature (credit also goes to Google search): SPFile link (pdf)

I tested SPFile.BackwardLinks and ForwardLinks properties. It seems that the BackwardLinks will list correct values immediately but ForwardLinks doesn’t do that until the file is checked in. For example, in CSDG 1234.ppt I create a link to 1.txt. Before checkin, 1.txt has CSDG 1234.ppt in BackwardLinks but CSDG 1234.ppt doesn’t have 1.txt in ForwardLinks, until I check in CSDG 1234.ppt. That’s interesting… But I guess it doesn’t really matter in our case.

I didn’t find a complete list of ‘parsed document types’ mentioned in above pdf file. So far, Word, Powerpoint and HTM files are working.

Things worth noting:

  • File is updated immediately after calling ReplaceLink – no need to call Update().
  • For HTM file, ForwardLinks include all kinds of resources linked in the main HTM file: htm, image, js, xml etc. It does NOT combine duplicated links.
  • If SPLink.IsBroken is false, it does NOT mean that the link is valid. For a external link (such as http://google.com), this property is always false. You have to also check IsInternal to detect an internal broken link. That means you know for sure it’s a broken link when (IsInternal==true && IsBroken==true). ServerRelativeUrl can not be used to determine that. In one particular case, there is link pointing to ../../../../../a/foler/strucutre/not/exist/afile.doc, the IsBroken property is false. The IsInternal value is false also, and ServerRealtiveUrl is ../../../../../a/foler/strucutre/not/exist/afile.doc.

Follow

Get every new post delivered to your Inbox.