Friday, July 13, 2012

Move a document into a document set

Document set is a new feature in SharePoint 2010. It is very neat to be able to group documents together with metadata, workflows, etc. Just one small thing. There is no way to move existing documents into document sets. I recently had to come up with a solution to this for a customer and I found this gem after some searching, http://gilleslauwers.wordpress.com/2011/05/31/move-a-file-to-a-document-set/.

I changed two things to make the solution perfect.

1. Added {SiteUrl} to options.url in Elements.xml to make it work for site collections with a managed path:

options.url = '{SiteUrl}/_layouts/Sam.MoveToDocumentSet/ChooseDocumentSet.aspx?ListId={ListId}&ItemId={ItemId}';

2. Changed the CAML query to display all document sets, even those of custom content types:

query.Query = "<Where><Eq><FieldRef Name='FSObjType' /><Value Type='Lookup'>1</Value></Eq></Where>";

I would rather develop features that does something customer specific than do this, which should be included in the product.

Yet another day in SharePoint paradise...

No comments:

Post a Comment