Monday, October 27, 2008

Using SharePoint 2007 "RootFolder" query string parameter to navigate to a folder - Gotcha!

I had a project which wanted to use a SharePoint document library in order to store documents for a Dynamics CRM 4.0 entity. The solution we came up with was to point to the AllItems.aspx, strip the chrome of the page and show the Document Library webpart with toolbar in an IFrame. Sound crazy? Maybe so.

All was good. It shows the library, you can interact with the parts and we stripped chrome using CSS. However, we wanted to go to a SUBFOLDER in the document library. While we could point to the SUBFOLDER, interacting with any of the toolbar buttons acted on the root of the library - NOT THE FOLDER!

The more we looked into it, we discovered that:

  1. The FolderCTID and View is NOT required in the URL to get to a subfolder correctly.
  2. The RootFolder query string parameter is required.
  3. The RootFolder query string parameter MUST BE ESCAPED (%2f for slashes, %2d for dashes, etc.)
  4. The RootFolder query string parameter Url is relative from the root of the site.
  5. The RootFolder query string parameter (and this is the IMPORTANT point) is CASE SENSITIVE ON HOW YOU CREATED THE Sites and Folders!

An Example link to a document library AllItems page would look like this:

http://sharepoint/sites/TheSites/TheDocumentLibrary/Forms/AllItems.aspx

If there was a folder called "WhooHaw":

http://sharepoint/sites/TheSites/TheDocumentLibrary/Forms/AllItems.aspx?RootFolder=%2fTheSites%2fTheDocumentLibrary%2fWhooHaw

But you can't do this:

http://sharepoint/sites/TheSites/TheDocumentLibrary/Forms/AllItems.aspx?RootFolder=%2fthesites%2fthedocumentlibrary%2fwhoohaw

But you can't do this:

http://sharepoint/sites/TheSites/TheDocumentLibrary/Forms/AllItems.aspx?RootFolder=%2fTHESITES%2fTHEDOCUMENTLIBRARY%2fWHOOHAW

So, if you're going to put a document library in an IFRAME, make sure you create your RootFolder query string parameter correctly, or you'll find yourself unhappy with actions in the web part.

3 comments:

mrparrothead said...

Hi,

I'm trying do the same thing that you did here in this post. I have the library display correctly and the toolbar displays. What I'm finding is the 'Upload' is uploading the document to the top level folder and not the subfolder being displayed.

What is happening is that when I click 'Upload' I go to SharePoint's Upload.aspx page. At that point SharePoint adds a RootFolder parameter too. So now there is the one SharePoint added and mine. Theirs comes first in the query string which is probably why it posts there.

Did you have this issues too?

Thanks! Ed

gbelzile said...

Same problem with the upload behavior... Any answer to this?

Anonymous said...

Thanks for this post. This is exactly what I was looking for! I'm experiencing a very similar problem and had figured out that there was an issue with the url but you've saved me time in trying to work out the rules! Thanks!