1

I have no hopes that there is an easy answer to this, but still...

I have 2 lists - Templates and Library. In Templates I only have 1 item. This item can be manually copied with a workflow assigned to the Templates list. However, when it is copied, the newly created item in list Library has the same creation date as the original. I want it to have the real creation date - the 'today' date of when the workflow copied the new item.

Is there an easy way to do it? If not - can you give me some hints on what the hard way would be?

The version of sharepoint is foundation 2010.

1

One of the methods of SPFolder.Files is Add, and one of the signatures of that method is explained here:

http://msdn.microsoft.com/en-us/library/ms480295.aspx

Basically, you should be able to create a hashtable with all of the metadata you want to move over (and, more importantly in this case, none of the metadata you do not), and then call the Add method with the URL, the stream, and the hashtable. If you don't include the "Author" and "Created" fields in the hashtable, they won't be imported and you should see "System Account" and today's date in those fields, respectively.

There is also a signature of that method that allows you to specifically designate the Author and Editor fields as well as the Created and Modified fields:

http://msdn.microsoft.com/en-us/library/ms439259.aspx

Note that this way doesn't allow you to bring in any other metadata, so if you have any custom fields, they aren't going to work (and you're better off using the hashtable instead).

0

That is the expected behavior with Copy. Instead of copying the item, create a new item, which will give it the proper created date, and just use the column values in the Template list item for the new item in the Library list.

  • Thanks for the answer. I actually need to use the 'copy' function, because the item is an .aspx file, customized with web parts. The 'copy' workflow retains all of the webparts in the new file, so it is easy to edit them from the second list. – P.G Jun 4 '13 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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