Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Due to security issues, I can't access this site from office and can't take away the code either. I have to explain from what I recall about all my tries and fails.

I am using c# to create Document sets. I managed to define Author and creation Date with the properties in a Hashtable when adding the document set. The table also defines Modified and Modified by values with the same DateTime and SPuser values. The problem is that in Sharepoint the values I set are not shown. The account used to run the program and the DateTime of execution are shown instead. This makes sense since the account is the one who created the Item at this time. But where are my values and is there a way to change them?

Using a console output to control all what's in myCreatedDocumentSet.Item[0 to 30], I see the values I defined but nothing about the ones shown in the Library. I obviously miss something about the way Document sets are showing Modified and Modified values. Is there a metadata property I should attach to the document set?

I am lost and this time Google did not save my day of unsuccesful attempts. If needed I'll post later a manual copy of my last not working code.

share|improve this question
add comment

1 Answer 1

You need to keep in mind that Document Sets are just folders on steroids.

I tried to make HashTable approach to work without any luck. But this code will do the job:

using (var site = new SPSite("http://myultracooltestsite"))
{
    using (var web = site.OpenWeb())
    {
        SPList list = web.Lists["MyCoolDocLib"];
        DocumentSet ds = DocumentSet.Create(list.RootFolder, "TEST", 
                   list.ContentTypes["Document Set"].Id, new Hashtable());
        //random site user
        ds.Folder.Item["Editor"] = web.SiteUsers.GetByID(20); 
        //add 10 years to see the difference 
        ds.Folder.Item["Modified"] = DateTime.Now.AddYears(10); 
        ds.Folder.Item.UpdateOverwriteVersion();
    }
}

While researching I also found some interesting articles (not quite dealing with this issue):

share|improve this answer
    
+1 for "folders on steroids" lol –  RJ Cuthbertson Jan 13 at 17:14
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.